|
|
#ifdef TEST
#include "unity.h"
#include "logarithmus.h"
#include "exponent.h"
void setUp(void) { }
void tearDown(void) { }
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);
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); }
void test_ln_with_zero_and_negative_numbers(void){ double r1, r2, r3;
r1 = logN(0.0, 0.000001); r2 = logN(-1.0, 0.000001); r3 = logN(-2.5, 0.000001);
TEST_ASSERT_EQUAL_DOUBLE(-1.0, r1); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r2); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r3); }
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);
TEST_ASSERT_EQUAL_DOUBLE(-1.0, r1); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r2); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r3); TEST_ASSERT_EQUAL_DOUBLE(-1.0, r4); }
#endif // TEST
|