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.

129 lines
2.6 KiB

1 year 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. void test_minitaschenrechner_0_durch_5(void)
  80. {
  81. float result = dividieren(0, 5);
  82. TEST_ASSERT_EQUAL(0, result);
  83. }
  84. // test rest
  85. void test_minitaschenrechner_14_rest_5(void)
  86. {
  87. float result = rest(14, 5);
  88. TEST_ASSERT_EQUAL(4, result);
  89. }
  90. void test_minitaschenrechner_1_rest_7(void)
  91. {
  92. float result = rest(0, 7);
  93. TEST_ASSERT_EQUAL(0, result);
  94. }
  95. // test groesster gemeinsammer Teiler
  96. void test_minitaschenrechner_120_groesster_gemeinsammer_teiler_30(void)
  97. {
  98. float result = groesster_gemeinsammer_teiler(120, 30);
  99. TEST_ASSERT_EQUAL(30, result);
  100. }
  101. // test kleinstes gemeinsammes Vielfaches
  102. void test_minitaschenrechner_120_kleinstes_gemeinsammes_vielfaches_50(void)
  103. {
  104. float result = kleinstes_gemeinsammes_vielfaches(120, 50);
  105. TEST_ASSERT_EQUAL(600, result);
  106. }
  107. #endif // TEST