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.

65 lines
1.3 KiB

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