From 1ce4f54dd0daa74f4e08931763f1dbef36d47ed1 Mon Sep 17 00:00:00 2001 From: fdai7848 Date: Fri, 2 Feb 2024 19:22:37 +0100 Subject: [PATCH] add test for logarithmic function to base 2 --- test/test_logarithmus.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_logarithmus.c b/test/test_logarithmus.c index d606c97..3faad09 100644 --- a/test/test_logarithmus.c +++ b/test/test_logarithmus.c @@ -97,5 +97,23 @@ void test_logarithmic_function_to_base_10(void){ TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.0, r6); } +void test_logarithmic_function_to_base_2(void){ + double r1, r2, r3, r4, r5, r6; + + r1 = logBin(1024.0); + r2 = logBin(1024.8742); + r3 = logBin(900.587); + r4 = logBin(78.341); + r5 = logBin(0.34979); + r6 = logBin(1.0); + + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 10.0, r1); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 10.001231, r2); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 9.814721, r3); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 6.291695, r4); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, -1.515439, r5); + TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.0, r6); +} + #endif // TEST \ No newline at end of file