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.

92 lines
1.9 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "funktionen.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_square(void) {
  11. float result = square(2.5);
  12. /* assert */
  13. TEST_ASSERT_EQUAL_FLOAT(6.25, result);
  14. }
  15. void test_squareRoot_for_9(void) {
  16. float result = squareRoot(9.0);
  17. TEST_ASSERT_EQUAL_FLOAT(3.0, result);
  18. }
  19. void test_cube_for_2(void) {
  20. float result = cube(2.0);
  21. TEST_ASSERT_EQUAL_FLOAT(8.0, result);
  22. }
  23. void test_cubeRoot_for_27(void) {
  24. float result = cubeRoot(27.0);
  25. TEST_ASSERT_EQUAL_FLOAT(3.0, result);
  26. }
  27. void test_absolute_for_5(void) {
  28. float result = absolute(-5.0);
  29. TEST_ASSERT_EQUAL_FLOAT(5.0, result);
  30. }
  31. void test_logarithm_for_100(void) {
  32. float result = logarithm(100.0);
  33. TEST_ASSERT_FLOAT_WITHIN(0.000001, 2.0, result);
  34. }
  35. void test_naturalLogarithm_for_100(void) {
  36. float result = naturalLogarithm(100.0);
  37. TEST_ASSERT_FLOAT_WITHIN(0.000001, 4.60517, result);
  38. }
  39. void test_factorial(void) {
  40. int result = factorial(5);
  41. TEST_ASSERT_EQUAL_INT(120, result);
  42. }
  43. void test_floorValue(void) {
  44. float result = floorValue(5.7);
  45. TEST_ASSERT_EQUAL_FLOAT(5.0, result);
  46. }
  47. void test_ceilingValue(void) {
  48. float result = ceilingValue(5.2);
  49. TEST_ASSERT_EQUAL_FLOAT(6.0, result);
  50. }
  51. void test_absoluteDifference(void) {
  52. float result = absoluteDifference(8.0, 4.5);
  53. TEST_ASSERT_FLOAT_WITHIN(0.000001, 3.5, result);
  54. }
  55. void test_maximum(void) {
  56. float result = maximum(5.0, 9.0);
  57. TEST_ASSERT_FLOAT_WITHIN(0.000001, 9.0, result);
  58. }
  59. void test_minimum(void) {
  60. float result = minimum(5.0, 9.0);
  61. TEST_ASSERT_FLOAT_WITHIN(0.000001, 5.0, result);
  62. }
  63. void test_average(void) {
  64. float result = average(5.0, 9.0);
  65. TEST_ASSERT_FLOAT_WITHIN(0.000001, 7.0, result);
  66. }
  67. void test_remainderValue(void) {
  68. float result = remainderValue(10.5, 3.0);
  69. TEST_ASSERT_FLOAT_WITHIN(0.000001, 1.5, result);
  70. }
  71. #endif