From f43c8409fe94af90962bbb3a8005ed180a887616 Mon Sep 17 00:00:00 2001 From: fdai7848 Date: Wed, 31 Jan 2024 10:56:49 +0100 Subject: [PATCH] Add test for ln function for positive numbers --- src/exponent.h | 1 + test/test_exponent.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/exponent.h b/src/exponent.h index 8a09fec..c869156 100644 --- a/src/exponent.h +++ b/src/exponent.h @@ -4,5 +4,6 @@ double expI(double e, double num); double expIN(double e, double num); double exponential(double x); +double logN(double x, double eps); #endif // exponent.h \ No newline at end of file diff --git a/test/test_exponent.c b/test/test_exponent.c index e517280..8545529 100644 --- a/test/test_exponent.c +++ b/test/test_exponent.c @@ -69,6 +69,22 @@ void test_Exponent_with_negative_number(void){ TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.135335, r2); } +void test_ln_with_positive_number(void){ + double r1, r2, r3; + + r1 = logN(1.0, 0.000001); + r2 = logN(10.0, 0.000001); + r3 = logN(2.5, 0.000001); + + printf("Result 1: %lf\n", r1); + printf("Result 2: %lf\n", r2); + printf("Result 3: %lf\n", r3); + + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0, r1); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 2.302585, r2); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.916290, r3); +} + #endif // TEST \ No newline at end of file