diff --git a/build/test/cache/test_quizduell.c b/build/test/cache/test_quizduell.c index 9db6d81..34fd6ef 100644 --- a/build/test/cache/test_quizduell.c +++ b/build/test/cache/test_quizduell.c @@ -319,3 +319,225 @@ void test_pruefeAntwort_WrongAnswer(void) { ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); } + +void test_sportsCategoryInitialization(void) { + + Kategorie kategorien[3]; + + + + kategorien[2].fragen = (QuizFrage*)malloc(3 * 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 = 3; + + kategorien[2].joker = 1; + + + + do {if ((((kategorien[2].fragen)) != + + ((void *)0) + + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(117))));}} while(0); + + UnityAssertEqualString((const char*)(("In which sport is the term 'home run' used?")), (const char*)((kategorien[2].fragen[0].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(118)); + + UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(119)); + + UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(120)); + + UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(121)); + + UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(122)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[0].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(123), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualString((const char*)(("How many players are there normally on the pitch in a soccer/football team?")), (const char*)((kategorien[2].fragen[1].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(124)); + + UnityAssertEqualString((const char*)(("9")), (const char*)((kategorien[2].fragen[1].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(125)); + + UnityAssertEqualString((const char*)(("11")), (const char*)((kategorien[2].fragen[1].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(126)); + + UnityAssertEqualString((const char*)(("7")), (const char*)((kategorien[2].fragen[1].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(127)); + + UnityAssertEqualString((const char*)(("5")), (const char*)((kategorien[2].fragen[1].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(128)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[1].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualString((const char*)(("What sport is played on a pitch and has a 'wicket'?")), (const char*)((kategorien[2].fragen[2].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(130)); + + UnityAssertEqualString((const char*)(("Rugby")), (const char*)((kategorien[2].fragen[2].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(131)); + + UnityAssertEqualString((const char*)(("Cricket")), (const char*)((kategorien[2].fragen[2].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(132)); + + UnityAssertEqualString((const char*)(("American Football")), (const char*)((kategorien[2].fragen[2].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(133)); + + UnityAssertEqualString((const char*)(("Hockey")), (const char*)((kategorien[2].fragen[2].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(134)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[2].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(135), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((kategorien[2].anzahlFragen)), ( + + ((void *)0) + + ), (UNITY_UINT)(136), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((kategorien[2].joker)), ( + + ((void *)0) + + ), (UNITY_UINT)(137), UNITY_DISPLAY_STYLE_INT); + + + + free(kategorien[2].fragen); + + kategorien[2].fragen = + + ((void *)0) + + ; + +} + +void test_categorySelection_Cooking(void) { + + Kategorie kategorien[3]; + + + + char auswahl[50] = "Cooking"; + + + + int auswahlIndex = -1; + + + + for (int i = 0; i < 3; i++) { + + if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Mountains") == 0) { + + auswahlIndex = 0; + + break; + + } + + else if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Cooking") == 0) { + + auswahlIndex = 1; + + break; + + } + + else if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Sports") == 0) { + + auswahlIndex = 2; + + break; + + } + + } + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((auswahlIndex)), ( + + ((void *)0) + + ), (UNITY_UINT)(163), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/out/c/test_quizduell.o b/build/test/out/c/test_quizduell.o index 6317176..d36fcce 100644 Binary files a/build/test/out/c/test_quizduell.o and b/build/test/out/c/test_quizduell.o differ diff --git a/build/test/out/c/test_quizduell_runner.o b/build/test/out/c/test_quizduell_runner.o index 89550da..24748a0 100644 Binary files a/build/test/out/c/test_quizduell_runner.o and b/build/test/out/c/test_quizduell_runner.o differ diff --git a/build/test/out/test_quizduell.out b/build/test/out/test_quizduell.out index 1132a6b..fba414a 100755 Binary files a/build/test/out/test_quizduell.out and b/build/test/out/test_quizduell.out differ diff --git a/build/test/preprocess/files/test_quizduell.c b/build/test/preprocess/files/test_quizduell.c index 9db6d81..34fd6ef 100644 --- a/build/test/preprocess/files/test_quizduell.c +++ b/build/test/preprocess/files/test_quizduell.c @@ -319,3 +319,225 @@ void test_pruefeAntwort_WrongAnswer(void) { ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); } + +void test_sportsCategoryInitialization(void) { + + Kategorie kategorien[3]; + + + + kategorien[2].fragen = (QuizFrage*)malloc(3 * 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 = 3; + + kategorien[2].joker = 1; + + + + do {if ((((kategorien[2].fragen)) != + + ((void *)0) + + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(117))));}} while(0); + + UnityAssertEqualString((const char*)(("In which sport is the term 'home run' used?")), (const char*)((kategorien[2].fragen[0].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(118)); + + UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(119)); + + UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(120)); + + UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(121)); + + UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(122)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[0].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(123), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualString((const char*)(("How many players are there normally on the pitch in a soccer/football team?")), (const char*)((kategorien[2].fragen[1].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(124)); + + UnityAssertEqualString((const char*)(("9")), (const char*)((kategorien[2].fragen[1].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(125)); + + UnityAssertEqualString((const char*)(("11")), (const char*)((kategorien[2].fragen[1].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(126)); + + UnityAssertEqualString((const char*)(("7")), (const char*)((kategorien[2].fragen[1].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(127)); + + UnityAssertEqualString((const char*)(("5")), (const char*)((kategorien[2].fragen[1].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(128)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[1].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(129), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualString((const char*)(("What sport is played on a pitch and has a 'wicket'?")), (const char*)((kategorien[2].fragen[2].frage)), ( + + ((void *)0) + + ), (UNITY_UINT)(130)); + + UnityAssertEqualString((const char*)(("Rugby")), (const char*)((kategorien[2].fragen[2].antwortA)), ( + + ((void *)0) + + ), (UNITY_UINT)(131)); + + UnityAssertEqualString((const char*)(("Cricket")), (const char*)((kategorien[2].fragen[2].antwortB)), ( + + ((void *)0) + + ), (UNITY_UINT)(132)); + + UnityAssertEqualString((const char*)(("American Football")), (const char*)((kategorien[2].fragen[2].antwortC)), ( + + ((void *)0) + + ), (UNITY_UINT)(133)); + + UnityAssertEqualString((const char*)(("Hockey")), (const char*)((kategorien[2].fragen[2].antwortD)), ( + + ((void *)0) + + ), (UNITY_UINT)(134)); + + UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[2].korrekteAntwort)), ( + + ((void *)0) + + ), (UNITY_UINT)(135), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((kategorien[2].anzahlFragen)), ( + + ((void *)0) + + ), (UNITY_UINT)(136), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((kategorien[2].joker)), ( + + ((void *)0) + + ), (UNITY_UINT)(137), UNITY_DISPLAY_STYLE_INT); + + + + free(kategorien[2].fragen); + + kategorien[2].fragen = + + ((void *)0) + + ; + +} + +void test_categorySelection_Cooking(void) { + + Kategorie kategorien[3]; + + + + char auswahl[50] = "Cooking"; + + + + int auswahlIndex = -1; + + + + for (int i = 0; i < 3; i++) { + + if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Mountains") == 0) { + + auswahlIndex = 0; + + break; + + } + + else if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Cooking") == 0) { + + auswahlIndex = 1; + + break; + + } + + else if (kategorien[i].fragen != + + ((void *)0) + + && strcmp(auswahl, "Sports") == 0) { + + auswahlIndex = 2; + + break; + + } + + } + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((auswahlIndex)), ( + + ((void *)0) + + ), (UNITY_UINT)(163), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index 74b5aa1..ed0ab35 100644 --- a/build/test/results/test_casualQuiz.pass +++ b/build/test/results/test_casualQuiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.016587400001299102 +:time: 0.01713199999903736 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index b3fb1d7..8a5ec0c 100644 --- a/build/test/results/test_quizduell.pass +++ b/build/test/results/test_quizduell.pass @@ -31,12 +31,20 @@ :line: 102 :message: '' :unity_test_time: 0 +- :test: test_sportsCategoryInitialization + :line: 106 + :message: '' + :unity_test_time: 0 +- :test: test_categorySelection_Cooking + :line: 142 + :message: '' + :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 7 - :passed: 7 + :total: 9 + :passed: 9 :failed: 0 :ignored: 0 :stdout: [] -:time: 0.01651020000099379 +:time: 0.0320902000003116 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index 1090843..d28e2aa 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.016081800000392832 +:time: 0.01697989999956917 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index 77f7bcd..65b68ff 100644 --- a/build/test/results/test_wwm.pass +++ b/build/test/results/test_wwm.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.016533899999558344 +:time: 0.017033699999956298 diff --git a/build/test/runners/test_quizduell_runner.c b/build/test/runners/test_quizduell_runner.c index 10ec3ac..adf36b6 100644 --- a/build/test/runners/test_quizduell_runner.c +++ b/build/test/runners/test_quizduell_runner.c @@ -17,6 +17,8 @@ extern void test_createCategory2WithQuestions(void); extern void test_befreieKategorie(void); extern void test_pruefeAntwort_CorrectAnswer(void); extern void test_pruefeAntwort_WrongAnswer(void); +extern void test_sportsCategoryInitialization(void); +extern void test_categorySelection_Cooking(void); /*=======Mock Management=====*/ @@ -88,6 +90,8 @@ int main(void) 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); + run_test(test_sportsCategoryInitialization, "test_sportsCategoryInitialization", 106); + run_test(test_categorySelection_Cooking, "test_categorySelection_Cooking", 142); return UnityEnd(); } diff --git a/test/test_quizduell.c b/test/test_quizduell.c index 5639d1e..da21565 100644 --- a/test/test_quizduell.c +++ b/test/test_quizduell.c @@ -1,5 +1,6 @@ #ifdef TEST +#include #include #include "unity.h" #include "quizduell.h" @@ -139,4 +140,27 @@ void test_sportsCategoryInitialization(void) { free(kategorien[2].fragen); kategorien[2].fragen = NULL; } +void test_categorySelection_Cooking(void) { + Kategorie kategorien[MAX_CATEGORIES]; + + char auswahl[50] = "Cooking"; + + int auswahlIndex = -1; + + for (int i = 0; i < MAX_CATEGORIES; i++) { + if (kategorien[i].fragen != NULL && strcmp(auswahl, "Mountains") == 0) { + auswahlIndex = 0; + break; + } + else if (kategorien[i].fragen != NULL && strcmp(auswahl, "Cooking") == 0) { + auswahlIndex = 1; + break; + } + else if (kategorien[i].fragen != NULL && strcmp(auswahl, "Sports") == 0) { + auswahlIndex = 2; + break; + } + } + TEST_ASSERT_EQUAL(1, auswahlIndex); +} #endif //TEST \ No newline at end of file