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.

120 lines
3.1 KiB

  1. #ifdef TEST
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include "unity.h"
  5. #include "casualQuiz.h"
  6. // Test setup function
  7. void setUp(void) {
  8. }
  9. // Test teardown function
  10. void tearDown(void) {
  11. }
  12. void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
  13. int TESTeingabe = 1;
  14. int TESTindex = 0;
  15. int TESTrichtige_antwort[]={1};
  16. bool testfall;
  17. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  18. TEST_ASSERT_TRUE(testfall == true);
  19. }
  20. void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
  21. int TESTeingabe = 2;
  22. int TESTindex = 0;
  23. int TESTrichtige_antwort[]={2};
  24. bool testfall;
  25. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  26. TEST_ASSERT_TRUE(testfall == true);
  27. }
  28. void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
  29. int TESTeingabe = 3;
  30. int TESTindex = 0;
  31. int TESTrichtige_antwort[]={3};
  32. bool testfall;
  33. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  34. TEST_ASSERT_TRUE(testfall == true);
  35. }void test_FcheckaufRichtigkeit_correct_answer_atIndex4(void){
  36. int TESTeingabe = 4;
  37. int TESTindex = 0;
  38. int TESTrichtige_antwort[]={4};
  39. bool testfall;
  40. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  41. TEST_ASSERT_TRUE(testfall == true);
  42. }
  43. void test_FcheckaufRichtigkeit_incorrect_input_higher(void){
  44. int TESTeingabe = 5;
  45. int TESTindex = 0;
  46. int TESTrichtige_antwort[]={3};
  47. bool testfall;
  48. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  49. TEST_ASSERT_TRUE(testfall != true);
  50. }
  51. void test_FcheckaufRichtigkeit_incorrect_input_lower(void){
  52. int TESTeingabe = -1;
  53. int TESTindex = 0;
  54. int TESTrichtige_antwort[]={3};
  55. bool testfall;
  56. testfall = FcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
  57. TEST_ASSERT_TRUE(testfall != true);
  58. }
  59. void test_FzaehlernachAuswahl(void){
  60. bool richtig = true;
  61. int correct = 0;
  62. int answered = 0;
  63. int* correctP = &correct;
  64. int* answeredP = &answered;
  65. FzaehlernachAuswahl(richtig, answeredP, correctP);
  66. TEST_ASSERT_EQUAL_INT(1, correct);
  67. TEST_ASSERT_EQUAL_INT(1, answered);
  68. }
  69. void test_FzaehlernachAuswahl_bei1(void){
  70. bool richtig = true;
  71. int correct = 1;
  72. int answered = 1;
  73. int* correctP = &correct;
  74. int* answeredP = &answered;
  75. FzaehlernachAuswahl(richtig, answeredP, correctP);
  76. TEST_ASSERT_EQUAL_INT(2, correct);
  77. TEST_ASSERT_EQUAL_INT(2, answered);
  78. }
  79. void test_FzaehlernachAuswahl_falsch_bei_0(void){
  80. bool richtig = false;
  81. int correct = 0;
  82. int answered = 0;
  83. int* correctP = &correct;
  84. int* answeredP = &answered;
  85. FzaehlernachAuswahl(richtig, answeredP, correctP);
  86. TEST_ASSERT_EQUAL_INT(0, correct);
  87. TEST_ASSERT_EQUAL_INT(1, answered);
  88. }
  89. void test_FzaehlernachAuswahl_falsch_bei_1(void){
  90. bool richtig = false;
  91. int correct = 1;
  92. int answered = 1;
  93. int* correctP = &correct;
  94. int* answeredP = &answered;
  95. FzaehlernachAuswahl(richtig, answeredP, correctP);
  96. TEST_ASSERT_EQUAL_INT(1, correct);
  97. TEST_ASSERT_EQUAL_INT(2, answered);
  98. }
  99. #endif //Test