Browse Source

Unittest8

remotes/origin/Kevin
Kevin Schellberg 11 months ago
parent
commit
22da3396cb
  1. 12
      build/test/cache/test_quizduell.c
  2. BIN
      build/test/out/c/test_quizduell.o
  3. BIN
      build/test/out/c/test_quizduell_runner.o
  4. BIN
      build/test/out/test_quizduell.out
  5. 12
      build/test/preprocess/files/test_quizduell.c
  6. 2
      build/test/results/test_casualQuiz.pass
  7. 10
      build/test/results/test_quizduell.pass
  8. 2
      build/test/results/test_timequiz.pass
  9. 2
      build/test/results/test_wwm.pass
  10. 2
      build/test/runners/test_quizduell_runner.c
  11. 36
      test/test_quizduell.c

12
build/test/cache/test_quizduell.c

@ -307,3 +307,15 @@ void test_pruefeAntwort_CorrectAnswer(void) {
), (UNITY_UINT)(100), UNITY_DISPLAY_STYLE_INT);
}
void test_pruefeAntwort_WrongAnswer(void) {
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A');
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((pruefeAntwort(frage, 'B'))), (
((void *)0)
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT);
}

BIN
build/test/out/c/test_quizduell.o

BIN
build/test/out/c/test_quizduell_runner.o

BIN
build/test/out/test_quizduell.out

12
build/test/preprocess/files/test_quizduell.c

@ -307,3 +307,15 @@ void test_pruefeAntwort_CorrectAnswer(void) {
), (UNITY_UINT)(100), UNITY_DISPLAY_STYLE_INT);
}
void test_pruefeAntwort_WrongAnswer(void) {
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A');
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((pruefeAntwort(frage, 'B'))), (
((void *)0)
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT);
}

2
build/test/results/test_casualQuiz.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.01634360000025481
:time: 0.016587400001299102

10
build/test/results/test_quizduell.pass

@ -27,12 +27,16 @@
:line: 98
:message: ''
:unity_test_time: 0
- :test: test_pruefeAntwort_WrongAnswer
:line: 102
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 6
:passed: 6
:total: 7
:passed: 7
:failed: 0
:ignored: 0
:stdout: []
:time: 0.030828099999780534
:time: 0.01651020000099379

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.016310499999235617
:time: 0.016081800000392832

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.01756539999951201
:time: 0.016533899999558344

2
build/test/runners/test_quizduell_runner.c

@ -16,6 +16,7 @@ extern void test_MountainsFragen(void);
extern void test_createCategory2WithQuestions(void);
extern void test_befreieKategorie(void);
extern void test_pruefeAntwort_CorrectAnswer(void);
extern void test_pruefeAntwort_WrongAnswer(void);
/*=======Mock Management=====*/
@ -86,6 +87,7 @@ int main(void)
run_test(test_createCategory2WithQuestions, "test_createCategory2WithQuestions", 65);
run_test(test_befreieKategorie, "test_befreieKategorie", 86);
run_test(test_pruefeAntwort_CorrectAnswer, "test_pruefeAntwort_CorrectAnswer", 98);
run_test(test_pruefeAntwort_WrongAnswer, "test_pruefeAntwort_WrongAnswer", 102);
return UnityEnd();
}

36
test/test_quizduell.c

@ -103,4 +103,40 @@ void test_pruefeAntwort_WrongAnswer(void) {
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A');
TEST_ASSERT_EQUAL_INT(0, pruefeAntwort(frage, 'B'));
}
void test_sportsCategoryInitialization(void) {
Kategorie kategorien[MAX_CATEGORIES];
kategorien[2].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage));
kategorien[2].fragen[0] = erstelleFrage("In which sport is the term 'home run' used?", "Soccer/Football", "Baseball", "Tennis", "Golf", 'B');
kategorien[2].fragen[1] = erstelleFrage("How many players are there normally on the pitch in a soccer/football team?", "9", "11", "7", "5", 'B');
kategorien[2].fragen[2] = erstelleFrage("What sport is played on a pitch and has a 'wicket'?", "Rugby", "Cricket", "American Football", "Hockey", 'B');
kategorien[2].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY;
kategorien[2].joker = 1;
TEST_ASSERT_NOT_NULL(kategorien[2].fragen);
TEST_ASSERT_EQUAL_STRING("In which sport is the term 'home run' used?", kategorien[2].fragen[0].frage);
TEST_ASSERT_EQUAL_STRING("Soccer/Football", kategorien[2].fragen[0].antwortA);
TEST_ASSERT_EQUAL_STRING("Baseball", kategorien[2].fragen[0].antwortB);
TEST_ASSERT_EQUAL_STRING("Tennis", kategorien[2].fragen[0].antwortC);
TEST_ASSERT_EQUAL_STRING("Golf", kategorien[2].fragen[0].antwortD);
TEST_ASSERT_EQUAL('B', kategorien[2].fragen[0].korrekteAntwort);
TEST_ASSERT_EQUAL_STRING("How many players are there normally on the pitch in a soccer/football team?", kategorien[2].fragen[1].frage);
TEST_ASSERT_EQUAL_STRING("9", kategorien[2].fragen[1].antwortA);
TEST_ASSERT_EQUAL_STRING("11", kategorien[2].fragen[1].antwortB);
TEST_ASSERT_EQUAL_STRING("7", kategorien[2].fragen[1].antwortC);
TEST_ASSERT_EQUAL_STRING("5", kategorien[2].fragen[1].antwortD);
TEST_ASSERT_EQUAL('B', kategorien[2].fragen[1].korrekteAntwort);
TEST_ASSERT_EQUAL_STRING("What sport is played on a pitch and has a 'wicket'?", kategorien[2].fragen[2].frage);
TEST_ASSERT_EQUAL_STRING("Rugby", kategorien[2].fragen[2].antwortA);
TEST_ASSERT_EQUAL_STRING("Cricket", kategorien[2].fragen[2].antwortB);
TEST_ASSERT_EQUAL_STRING("American Football", kategorien[2].fragen[2].antwortC);
TEST_ASSERT_EQUAL_STRING("Hockey", kategorien[2].fragen[2].antwortD);
TEST_ASSERT_EQUAL('B', kategorien[2].fragen[2].korrekteAntwort);
TEST_ASSERT_EQUAL(MAX_QUESTIONS_PER_CATEGORY, kategorien[2].anzahlFragen);
TEST_ASSERT_EQUAL(1, kategorien[2].joker);
free(kategorien[2].fragen);
kategorien[2].fragen = NULL;
}
#endif //TEST
Loading…
Cancel
Save