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.

70 lines
1.4 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. TEST_ASSERT_EQUAL_FLOAT(6.25, result);
  13. }
  14. void test_squareRoot(void) {
  15. float result = squareRoot(9.0);
  16. TEST_ASSERT_EQUAL_FLOAT(3.0, result);
  17. }
  18. void test_cube(void) {
  19. float result = cube(2.0);
  20. TEST_ASSERT_EQUAL_FLOAT(8.0, result);
  21. }
  22. void test_cubeRoot(void) {
  23. float result = cubeRoot(27.0);
  24. TEST_ASSERT_EQUAL_FLOAT(3.0, result);
  25. }
  26. void test_absolute(void) {
  27. float result = absolute(-5.0);
  28. TEST_ASSERT_EQUAL_FLOAT(5.0, result);
  29. }
  30. void test_logarithm(void) {
  31. float result = logarithm(100.0);
  32. TEST_ASSERT_FLOAT_WITHIN(0.000001, 2.0, result);
  33. }
  34. void test_naturalLogarithm(void) {
  35. float result = naturalLogarithm(100.0);
  36. TEST_ASSERT_FLOAT_WITHIN(0.000001, 4.60517, result);
  37. }
  38. void test_power(void) {
  39. float result = power(2.0, 3.0);
  40. TEST_ASSERT_FLOAT_WITHIN(0.000001, 8.0, result);
  41. }
  42. void test_factorial(void) {
  43. int result = factorial(5);
  44. TEST_ASSERT_EQUAL_INT(120, result);
  45. }
  46. void test_floorValue(void) {
  47. float result = floorValue(5.7);
  48. TEST_ASSERT_EQUAL_FLOAT(5.0, result);
  49. }
  50. void test_ceilingValue(void) {
  51. float result = ceilingValue(5.2);
  52. TEST_ASSERT_EQUAL_FLOAT(6.0, result);
  53. // Add more test cases for different inputs and expected outputs
  54. }
  55. #endif