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.

43 lines
768 B

11 months ago
11 months ago
11 months ago
  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "exponent.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_DoubleBase_ForPositiveExponent(void){
  11. int r1, r2, r3;
  12. r1 = expI(2.0, -2.0);
  13. r2 = expI(3.0, -3.0);
  14. r3 = expI(4.0, 5.0);
  15. TEST_ASSERT_EQUAL_INT(4.0, r1);
  16. TEST_ASSERT_EQUAL_INT(-27.0, r2);
  17. TEST_ASSERT_EQUAL_INT(625.0, r3);
  18. }
  19. void test_DoubleBase_ForNegativeExponent(void){
  20. float r1, r2, r3;
  21. r1 = expIN(-1.0, 2.0);
  22. r2 = expIN(-3.0, -3.0);
  23. r3 = expIN(-2.0, -2.0);
  24. printf("Result 1: %f\n", r1);
  25. printf("Result 2: %f\n", r2);
  26. printf("Result 3: %f\n", r3);
  27. TEST_ASSERT_EQUAL_FLOAT(0.5, r1);
  28. TEST_ASSERT_EQUAL_FLOAT(-0.0370370373, r2);
  29. TEST_ASSERT_EQUAL_FLOAT(0.25, r3);
  30. }
  31. #endif // TEST