|
|
#ifdef TEST
#include "unity.h"
#include "reihen.h"
#include "exponent.h"
#include "logarithmus.h"
#include "util.h"
void setUp(void) { }
void tearDown(void) { }
void test_Exponent_with_positive_number(void){ double r1, r2, r3;
r1 = exponential(0.0); r2 = exponential(1.0); r3 = exponential(2.0);
TEST_ASSERT_EQUAL_DOUBLE(1.0, r1); TEST_ASSERT_DOUBLE_WITHIN(0.0001, 2.718282, r2); TEST_ASSERT_DOUBLE_WITHIN(0.0001, 7.389056, r3); }
void test_Exponent_with_negative_number(void){ double r1, r2, r3;
r1 = exponential(-1.0); r2 = exponential(-2.0);
TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.367879, r1); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.135335, r2); }
void test_pi(void){ double r1;
r1 = pi(1e-8); TEST_ASSERT_DOUBLE_WITHIN(0.0000001, 3.14159265, r1); }
void test_degrees_to_radians(){ double r1, r2, r3, r4;
r1 = radians(90.0); r2 = radians(180.0); r3 = radians(51.6); r4 = radians(36.97);
TEST_ASSERT_DOUBLE_WITHIN(0.000001, 1.570796, r1); TEST_ASSERT_DOUBLE_WITHIN(0.000001, pi(1e-8), r2); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.900589, r3); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.645248, r4); }
void test_sin(void){ double r1, r2, r3, r4;
r1 = sinD(50.0); r2 = sinD(90.0); r3 = sinD(36.97); r4 = sinD(180.0);
TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.766044, r1); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 1.0, r2); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.601396, r3); TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.0, r4); }
#endif // TEST
|