You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.5 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "reihen.h"
  4. #include "exponent.h"
  5. #include "logarithmus.h"
  6. #include "util.h"
  7. void setUp(void)
  8. {
  9. }
  10. void tearDown(void)
  11. {
  12. }
  13. void test_Exponent_with_positive_number(void){
  14. double r1, r2, r3;
  15. r1 = exponential(0.0);
  16. r2 = exponential(1.0);
  17. r3 = exponential(2.0);
  18. TEST_ASSERT_EQUAL_DOUBLE(1.0, r1);
  19. TEST_ASSERT_DOUBLE_WITHIN(0.0001, 2.718282, r2);
  20. TEST_ASSERT_DOUBLE_WITHIN(0.0001, 7.389056, r3);
  21. }
  22. void test_Exponent_with_negative_number(void){
  23. double r1, r2, r3;
  24. r1 = exponential(-1.0);
  25. r2 = exponential(-2.0);
  26. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.367879, r1);
  27. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.135335, r2);
  28. }
  29. void test_pi(void){
  30. double r1;
  31. r1 = pi(1e-8);
  32. TEST_ASSERT_DOUBLE_WITHIN(0.0000001, 3.14159265, r1);
  33. }
  34. void test_degrees_to_radians(){
  35. double r1, r2, r3, r4;
  36. r1 = radians(90.0);
  37. r2 = radians(180.0);
  38. r3 = radians(51.6);
  39. r4 = radians(36.97);
  40. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 1.570796, r1);
  41. TEST_ASSERT_DOUBLE_WITHIN(0.000001, pi(1e-8), r2);
  42. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.900589, r3);
  43. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.645248, r4);
  44. }
  45. void test_sin(void){
  46. double r1, r2, r3, r4;
  47. r1 = sinD(50.0);
  48. r2 = sinD(90.0);
  49. r3 = sinD(36.97);
  50. r4 = sinD(180.0);
  51. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.766044, r1);
  52. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 1.0, r2);
  53. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.601396, r3);
  54. TEST_ASSERT_DOUBLE_WITHIN(0.000001, 0.0, r4);
  55. }
  56. #endif // TEST