From 109ea482008568a98d634a6007b7328efa8483ec Mon Sep 17 00:00:00 2001 From: fdai7848 Date: Fri, 2 Feb 2024 17:06:25 +0100 Subject: [PATCH] add tests for log function with integers --- test/test_logarithmus.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/test/test_logarithmus.c b/test/test_logarithmus.c index e8fedfe..6461bba 100644 --- a/test/test_logarithmus.c +++ b/test/test_logarithmus.c @@ -40,15 +40,10 @@ void test_ln_with_zero_and_negative_numbers(void){ void test_logarithmic_function_with_edge_cases(void){ double r1, r2, r3, r4; - r1 = logX(0, 10); - r2 = logX(-1.0, 9); - r3 = logX(1, 18); - r4 = logX(3, 0); - - printf("%lf\n", r1); - printf("%lf\n", r2); - printf("%lf\n", r3); - printf("%lf\n", r4); + r1 = logX(0, 10.0); + r2 = logX(-1.0, 9.0); + r3 = logX(1.0, 18.0); + r4 = logX(3.0, 0.0); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r1); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r2); @@ -56,5 +51,19 @@ void test_logarithmic_function_with_edge_cases(void){ TEST_ASSERT_EQUAL_DOUBLE(-1.0, r4); } +void test_logarithmic_function_with_integers(void){ + double r1, r2, r3, r4; + + r1 = logX(0.5, 48.0); + r2 = logX(2.0, 8.0); + r3 = logX(3.2, 18.0); + r4 = logX(6.0, 36.0); + + TEST_ASSERT_DOUBLE_WITHIN(0.000001, -5.584962, r1); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 3.0, r2); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 2.484950, r3); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 2.0, r4); +} + #endif // TEST \ No newline at end of file