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.

97 lines
1.8 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "minirechner.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. // test addition
  11. void test_minitaschenrechner_3_plus_4(void)
  12. {
  13. float result = addieren(3, 4);
  14. TEST_ASSERT_EQUAL(7, result);
  15. }
  16. void test_minitaschenrechner_float_plus_float(void)
  17. {
  18. float result = addieren(3.1, 4.2);
  19. TEST_ASSERT_EQUAL(7.3, result);
  20. }
  21. void test_minitaschenrechner_minus1_plus_minus3(void)
  22. {
  23. float result = addieren(-1, -3);
  24. TEST_ASSERT_EQUAL(-4, result);
  25. }
  26. void test_minitaschenrechner_0_plus_2(void)
  27. {
  28. float result = addieren(0, 2);
  29. TEST_ASSERT_EQUAL(2, result);
  30. }
  31. // test subtraktion
  32. void test_minitaschenrechner_5_minus_2(void)
  33. {
  34. float result = subtrahieren(5, 2);
  35. TEST_ASSERT_EQUAL(3, result);
  36. }
  37. void test_minitaschenrechner_float_minus_float(void)
  38. {
  39. float result = subtrahieren(2.7, 1.3);
  40. TEST_ASSERT_EQUAL(1.4, result);
  41. }
  42. void test_minitaschenrechner_minus7_minus_minus3(void)
  43. {
  44. float result = subtrahieren(-7, -3);
  45. TEST_ASSERT_EQUAL(-4, result);
  46. }
  47. void test_minitaschenrechner_4_minus_0(void)
  48. {
  49. float result = subtrahieren(4, 0);
  50. TEST_ASSERT_EQUAL(4, result);
  51. }
  52. // test multiplikation
  53. void test_minitaschenrechner_8_mal_3(void)
  54. {
  55. float result = multiplizieren(8, 3);
  56. TEST_ASSERT_EQUAL(24, result);
  57. }
  58. void test_minitaschenrechner_minus3_mal_minus4(void)
  59. {
  60. float result = multiplizieren(-3, -4);
  61. TEST_ASSERT_EQUAL(12, result);
  62. }
  63. void test_minitaschenrechner_0_mal_5(void)
  64. {
  65. float result = multiplizieren(0, 5);
  66. TEST_ASSERT_EQUAL(0, result);
  67. }
  68. // test dividieren
  69. void test_minitaschenrechner_9_durch_3(void)
  70. {
  71. float result = dividieren(9, 3);
  72. TEST_ASSERT_EQUAL(3, result);
  73. }
  74. void test_minitaschenrechner_minus6_durch_minus2(void)
  75. {
  76. float result = dividieren(-6, -2);
  77. TEST_ASSERT_EQUAL(3, result);
  78. }
  79. #endif // TEST