Browse Source
Merge branch 'Kevin' into 'main'
Merge branch 'Kevin' into 'main'
Kevin See merge request fdai7760/the-quizstars!1main
fdai8033
11 months ago
37 changed files with 1634 additions and 43 deletions
-
4build/test/cache/defines_dependency.yml
-
22build/test/cache/input.yml
-
543build/test/cache/test_quizduell.c
-
10build/test/dependencies/cmock.d
-
0build/test/dependencies/force_build
-
1build/test/dependencies/quizduell.d
-
4build/test/dependencies/test_casualQuiz_runner.d
-
5build/test/dependencies/test_quizduell.d
-
4build/test/dependencies/test_quizduell_runner.d
-
4build/test/dependencies/test_timequiz_runner.d
-
4build/test/dependencies/test_wwm_runner.d
-
6build/test/dependencies/unity.d
-
BINbuild/test/out/c/cmock.o
-
BINbuild/test/out/c/quizduell.o
-
BINbuild/test/out/c/test_casualQuiz.o
-
BINbuild/test/out/c/test_casualQuiz_runner.o
-
BINbuild/test/out/c/test_quizduell.o
-
BINbuild/test/out/c/test_quizduell_runner.o
-
BINbuild/test/out/c/test_timequiz.o
-
BINbuild/test/out/c/test_timequiz_runner.o
-
BINbuild/test/out/c/test_wwm.o
-
BINbuild/test/out/c/test_wwm_runner.o
-
BINbuild/test/out/c/unity.o
-
BINbuild/test/out/test_casualQuiz.out
-
BINbuild/test/out/test_quizduell.out
-
BINbuild/test/out/test_timequiz.out
-
BINbuild/test/out/test_wwm.out
-
543build/test/preprocess/files/test_quizduell.c
-
4build/test/preprocess/includes/test_quizduell.c
-
2build/test/results/test_casualQuiz.pass
-
44build/test/results/test_quizduell.pass
-
2build/test/results/test_timequiz.pass
-
2build/test/results/test_wwm.pass
-
52build/test/runners/test_quizduell_runner.c
-
206src/quizduell.c
-
25src/quizduell.h
-
190test/test_quizduell.c
@ -1 +1,3 @@ |
|||||
--- {} |
|
||||
|
--- |
||||
|
src/quizduell.c: |
||||
|
- TEST |
@ -0,0 +1,543 @@ |
|||||
|
#include "src/quizduell.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_erstelleFrage(void) { |
||||
|
|
||||
|
QuizFrage testFrage = erstelleFrage("Testfrage", "AntwortA", "AntwortB", "AntwortC", "AntwortD", 'A'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Testfrage")), (const char*)((testFrage.frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(15)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortA")), (const char*)((testFrage.antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(16)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortB")), (const char*)((testFrage.antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(17)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortC")), (const char*)((testFrage.antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(18)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortD")), (const char*)((testFrage.antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('A')), (UNITY_INT)(UNITY_INT8 )((testFrage.korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(20), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_CookingFragen(void) { |
||||
|
|
||||
|
Kategorie kategorien[3]; |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].fragen[0] = erstelleFrage("Which Ingredient is used traditionally for Pesto?", "Tomatoes", "Basil", "Spinach", "Oregano", 'B'); |
||||
|
|
||||
|
kategorien[1].fragen[1] = erstelleFrage("Which meal is known for its usage of rice?", "Lasagna", "Sushi", "Pizza", "Hamburger", 'B'); |
||||
|
|
||||
|
kategorien[1].fragen[2] = erstelleFrage("Which color has a ripe banana?", "Red", "Green", "Yellow", "Orange", 'C'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].anzahlFragen = 3; |
||||
|
|
||||
|
kategorien[1].joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Which Ingredient is used traditionally for Pesto?")), (const char*)((kategorien[1].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(35)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tomatoes")), (const char*)((kategorien[1].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(36)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Basil")), (const char*)((kategorien[1].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(37)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Spinach")), (const char*)((kategorien[1].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(38)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Oregano")), (const char*)((kategorien[1].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(39)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('B')), (UNITY_INT)(UNITY_INT8 )((kategorien[1].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[1].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_MountainsFragen(void) { |
||||
|
|
||||
|
Kategorie kategorien[3]; |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].fragen[0] = erstelleFrage("Whats the height of the Zugspitze?", "2482 Meter", "2867 Meter", "2962 Meter", "3173 Meter", 'C'); |
||||
|
|
||||
|
kategorien[0].fragen[1] = erstelleFrage("In which Federal State is the Zugspitze?", "Bayern", "Baden-Wuerttemberg", "Hessen", "Thueringen", 'A'); |
||||
|
|
||||
|
kategorien[0].fragen[2] = erstelleFrage("Which Mountain is the highest following after the Zugspitze?", "Grossglockner", "Watzmann", "Feldberg", "Meissner", 'B'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].anzahlFragen = 3; |
||||
|
|
||||
|
kategorien[0].joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Whats the height of the Zugspitze?")), (const char*)((kategorien[0].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(57)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2482 Meter")), (const char*)((kategorien[0].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(58)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2867 Meter")), (const char*)((kategorien[0].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(59)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2962 Meter")), (const char*)((kategorien[0].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(60)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("3173 Meter")), (const char*)((kategorien[0].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(61)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('C')), (UNITY_INT)(UNITY_INT8 )((kategorien[0].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(62), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[0].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_createCategory2WithQuestions(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; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("In which sport is the term 'home run' used?")), (const char*)((kategorien[2].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(78)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(79)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(80)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(81)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(82)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('B')), (UNITY_INT)(UNITY_INT8 )((kategorien[2].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(83), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[2].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_befreieKategorie(void) { |
||||
|
|
||||
|
Kategorie testKategorie; |
||||
|
|
||||
|
testKategorie.fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
testKategorie.anzahlFragen = 3; |
||||
|
|
||||
|
testKategorie.joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
befreieKategorie(&testKategorie); |
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if ((((testKategorie.fragen)) == |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
)) {} else {UnityFail( (((" Expected NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(95))));}} while(0); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((testKategorie.anzahlFragen)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(96), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((testKategorie.joker)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(97), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_pruefeAntwort_CorrectAnswer(void) { |
||||
|
|
||||
|
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((pruefeAntwort(frage, 'A'))), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(101), 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)(105), 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)(118))));}} 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)(119)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(120)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(121)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(122)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(123)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(124), 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)(125)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("9")), (const char*)((kategorien[2].fragen[1].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(126)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("11")), (const char*)((kategorien[2].fragen[1].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(127)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("7")), (const char*)((kategorien[2].fragen[1].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(128)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("5")), (const char*)((kategorien[2].fragen[1].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(129)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[1].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(130), 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)(131)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Rugby")), (const char*)((kategorien[2].fragen[2].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(132)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Cricket")), (const char*)((kategorien[2].fragen[2].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(133)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("American Football")), (const char*)((kategorien[2].fragen[2].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(134)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Hockey")), (const char*)((kategorien[2].fragen[2].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(135)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[2].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(136), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((kategorien[2].anzahlFragen)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(137), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((kategorien[2].joker)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(138), 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)(164), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -1,6 +1,6 @@ |
|||||
build/test/out/c/cmock.o: \ |
build/test/out/c/cmock.o: \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1 @@ |
|||||
|
build/test/out/c/quizduell.o: src/quizduell.c src/quizduell.h |
@ -1,4 +1,4 @@ |
|||||
build/test/out/c/test_casualQuiz_runner.o: \ |
build/test/out/c/test_casualQuiz_runner.o: \ |
||||
build/test/runners/test_casualQuiz_runner.c \ |
build/test/runners/test_casualQuiz_runner.c \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1 +1,4 @@ |
|||||
build/test/out/c/test_quizduell.o: test/test_quizduell.c |
|
||||
|
build/test/out/c/test_quizduell.o: test/test_quizduell.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
||||
|
src/quizduell.h |
@ -1,4 +1,4 @@ |
|||||
build/test/out/c/test_quizduell_runner.o: \ |
build/test/out/c/test_quizduell_runner.o: \ |
||||
build/test/runners/test_quizduell_runner.c \ |
build/test/runners/test_quizduell_runner.c \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1,4 +1,4 @@ |
|||||
build/test/out/c/test_timequiz_runner.o: \ |
build/test/out/c/test_timequiz_runner.o: \ |
||||
build/test/runners/test_timequiz_runner.c \ |
build/test/runners/test_timequiz_runner.c \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1,3 +1,3 @@ |
|||||
build/test/out/c/test_wwm_runner.o: build/test/runners/test_wwm_runner.c \ |
build/test/out/c/test_wwm_runner.o: build/test/runners/test_wwm_runner.c \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1,4 +1,4 @@ |
|||||
build/test/out/c/unity.o: \ |
build/test/out/c/unity.o: \ |
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|
||||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,543 @@ |
|||||
|
#include "src/quizduell.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) {} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_erstelleFrage(void) { |
||||
|
|
||||
|
QuizFrage testFrage = erstelleFrage("Testfrage", "AntwortA", "AntwortB", "AntwortC", "AntwortD", 'A'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Testfrage")), (const char*)((testFrage.frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(15)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortA")), (const char*)((testFrage.antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(16)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortB")), (const char*)((testFrage.antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(17)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortC")), (const char*)((testFrage.antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(18)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("AntwortD")), (const char*)((testFrage.antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('A')), (UNITY_INT)(UNITY_INT8 )((testFrage.korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(20), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void test_CookingFragen(void) { |
||||
|
|
||||
|
Kategorie kategorien[3]; |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].fragen[0] = erstelleFrage("Which Ingredient is used traditionally for Pesto?", "Tomatoes", "Basil", "Spinach", "Oregano", 'B'); |
||||
|
|
||||
|
kategorien[1].fragen[1] = erstelleFrage("Which meal is known for its usage of rice?", "Lasagna", "Sushi", "Pizza", "Hamburger", 'B'); |
||||
|
|
||||
|
kategorien[1].fragen[2] = erstelleFrage("Which color has a ripe banana?", "Red", "Green", "Yellow", "Orange", 'C'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[1].anzahlFragen = 3; |
||||
|
|
||||
|
kategorien[1].joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Which Ingredient is used traditionally for Pesto?")), (const char*)((kategorien[1].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(35)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tomatoes")), (const char*)((kategorien[1].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(36)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Basil")), (const char*)((kategorien[1].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(37)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Spinach")), (const char*)((kategorien[1].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(38)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Oregano")), (const char*)((kategorien[1].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(39)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('B')), (UNITY_INT)(UNITY_INT8 )((kategorien[1].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[1].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_MountainsFragen(void) { |
||||
|
|
||||
|
Kategorie kategorien[3]; |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].fragen[0] = erstelleFrage("Whats the height of the Zugspitze?", "2482 Meter", "2867 Meter", "2962 Meter", "3173 Meter", 'C'); |
||||
|
|
||||
|
kategorien[0].fragen[1] = erstelleFrage("In which Federal State is the Zugspitze?", "Bayern", "Baden-Wuerttemberg", "Hessen", "Thueringen", 'A'); |
||||
|
|
||||
|
kategorien[0].fragen[2] = erstelleFrage("Which Mountain is the highest following after the Zugspitze?", "Grossglockner", "Watzmann", "Feldberg", "Meissner", 'B'); |
||||
|
|
||||
|
|
||||
|
|
||||
|
kategorien[0].anzahlFragen = 3; |
||||
|
|
||||
|
kategorien[0].joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Whats the height of the Zugspitze?")), (const char*)((kategorien[0].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(57)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2482 Meter")), (const char*)((kategorien[0].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(58)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2867 Meter")), (const char*)((kategorien[0].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(59)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("2962 Meter")), (const char*)((kategorien[0].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(60)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("3173 Meter")), (const char*)((kategorien[0].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(61)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('C')), (UNITY_INT)(UNITY_INT8 )((kategorien[0].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(62), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[0].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_createCategory2WithQuestions(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; |
||||
|
|
||||
|
|
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("In which sport is the term 'home run' used?")), (const char*)((kategorien[2].fragen[0].frage)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(78)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(79)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(80)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(81)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(82)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('B')), (UNITY_INT)(UNITY_INT8 )((kategorien[2].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(83), UNITY_DISPLAY_STYLE_CHAR); |
||||
|
|
||||
|
|
||||
|
|
||||
|
free(kategorien[2].fragen); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_befreieKategorie(void) { |
||||
|
|
||||
|
Kategorie testKategorie; |
||||
|
|
||||
|
testKategorie.fragen = (QuizFrage*)malloc(3 * sizeof(QuizFrage)); |
||||
|
|
||||
|
testKategorie.anzahlFragen = 3; |
||||
|
|
||||
|
testKategorie.joker = 1; |
||||
|
|
||||
|
|
||||
|
|
||||
|
befreieKategorie(&testKategorie); |
||||
|
|
||||
|
|
||||
|
|
||||
|
do {if ((((testKategorie.fragen)) == |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
)) {} else {UnityFail( (((" Expected NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(95))));}} while(0); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((testKategorie.anzahlFragen)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(96), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((testKategorie.joker)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(97), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void test_pruefeAntwort_CorrectAnswer(void) { |
||||
|
|
||||
|
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((pruefeAntwort(frage, 'A'))), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(101), 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)(105), 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)(118))));}} 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)(119)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Soccer/Football")), (const char*)((kategorien[2].fragen[0].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(120)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Baseball")), (const char*)((kategorien[2].fragen[0].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(121)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Tennis")), (const char*)((kategorien[2].fragen[0].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(122)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Golf")), (const char*)((kategorien[2].fragen[0].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(123)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[0].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(124), 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)(125)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("9")), (const char*)((kategorien[2].fragen[1].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(126)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("11")), (const char*)((kategorien[2].fragen[1].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(127)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("7")), (const char*)((kategorien[2].fragen[1].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(128)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("5")), (const char*)((kategorien[2].fragen[1].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(129)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[1].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(130), 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)(131)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Rugby")), (const char*)((kategorien[2].fragen[2].antwortA)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(132)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Cricket")), (const char*)((kategorien[2].fragen[2].antwortB)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(133)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("American Football")), (const char*)((kategorien[2].fragen[2].antwortC)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(134)); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Hockey")), (const char*)((kategorien[2].fragen[2].antwortD)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(135)); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)(('B')), (UNITY_INT)((kategorien[2].fragen[2].korrekteAntwort)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(136), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((kategorien[2].anzahlFragen)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(137), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((kategorien[2].joker)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(138), 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)(164), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -1 +1,3 @@ |
|||||
--- [] |
|
||||
|
--- |
||||
|
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h |
||||
|
- src/quizduell.h |
@ -0,0 +1,206 @@ |
|||||
|
#include "quizduell.h" |
||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <string.h> |
||||
|
#include <ctype.h> |
||||
|
|
||||
|
int pruefeAntwort(QuizFrage frage, char antwort) { |
||||
|
return (frage.korrekteAntwort == antwort); |
||||
|
} |
||||
|
|
||||
|
QuizFrage erstelleFrage(const char* frage, const char* antwortA, const char* antwortB, const char* antwortC, const char* antwortD, char korrekteAntwort) { |
||||
|
QuizFrage neueFrage; |
||||
|
strcpy(neueFrage.frage, frage); |
||||
|
strcpy(neueFrage.antwortA, antwortA); |
||||
|
strcpy(neueFrage.antwortB, antwortB); |
||||
|
strcpy(neueFrage.antwortC, antwortC); |
||||
|
strcpy(neueFrage.antwortD, antwortD); |
||||
|
neueFrage.korrekteAntwort = korrekteAntwort; |
||||
|
return neueFrage; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
int spieleKategorie(Kategorie* kategorie) { |
||||
|
int punktzahl = 0; |
||||
|
int jokerVerwendet = 0; |
||||
|
|
||||
|
for (int i = 0; i < kategorie->anzahlFragen; i++) { |
||||
|
char benutzerAntwort[10]; |
||||
|
|
||||
|
printf("\nQuestion %d:\n%s", i + 1, kategorie->fragen[i].frage); |
||||
|
|
||||
|
char jokerAntwort[10]; |
||||
|
|
||||
|
do { |
||||
|
printf("\nA) %s\nB) %s\nC) %s\nD) %s\n", kategorie->fragen[i].antwortA, kategorie->fragen[i].antwortB, kategorie->fragen[i].antwortC, kategorie->fragen[i].antwortD); |
||||
|
|
||||
|
if (!jokerVerwendet) { |
||||
|
printf("\nDo you want to use the joker? (Y/N): "); |
||||
|
scanf("%s", jokerAntwort); |
||||
|
printf(jokerAntwort); |
||||
|
|
||||
|
if (toupper(jokerAntwort[0]) == 'Y') { |
||||
|
if (kategorie->joker > 0) { |
||||
|
kategorie->joker -= 1; |
||||
|
jokerVerwendet = 1; |
||||
|
printf("Joker inserted! Two incorrect answer options were deleted.\n"); |
||||
|
|
||||
|
char korrekteAntwort = kategorie->fragen[i].korrekteAntwort; |
||||
|
int gestrichen = 0; |
||||
|
|
||||
|
for (char option = 'A'; option <= 'D'; option++) { |
||||
|
if (option != korrekteAntwort && gestrichen < 2) { |
||||
|
switch (option) { |
||||
|
case 'A': |
||||
|
strcpy(kategorie->fragen[i].antwortA, "XXXXXX"); |
||||
|
gestrichen++; |
||||
|
break; |
||||
|
case 'B': |
||||
|
strcpy(kategorie->fragen[i].antwortB, "XXXXXX"); |
||||
|
gestrichen++; |
||||
|
break; |
||||
|
case 'C': |
||||
|
strcpy(kategorie->fragen[i].antwortC, "XXXXXX"); |
||||
|
gestrichen++; |
||||
|
break; |
||||
|
case 'D': |
||||
|
strcpy(kategorie->fragen[i].antwortD, "XXXXXX"); |
||||
|
gestrichen++; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Zeigt die Antworten erneut an |
||||
|
printf("\nA) %s\nB) %s\nC) %s\nD) %s\n", kategorie->fragen[i].antwortA, kategorie->fragen[i].antwortB, kategorie->fragen[i].antwortC, kategorie->fragen[i].antwortD); |
||||
|
|
||||
|
break; |
||||
|
|
||||
|
} |
||||
|
else { |
||||
|
printf("No Joker left. Choose a different Category.\n"); |
||||
|
} |
||||
|
} |
||||
|
else if (toupper(jokerAntwort[0]) == 'N') { |
||||
|
break; // Beendet die Schleife, wenn der Spieler keinen Joker verwenden möchte |
||||
|
} |
||||
|
else { |
||||
|
printf("Invalid input. Please type in 'Y'' for yes or 'N' for no.\n"); |
||||
|
} |
||||
|
} |
||||
|
else { |
||||
|
break; // Wenn der Joker bereits verwendet wurde, beendet die Schleife ohne nachzufragen |
||||
|
} |
||||
|
|
||||
|
printf("Your answer: "); |
||||
|
scanf("%s", benutzerAntwort); |
||||
|
|
||||
|
benutzerAntwort[0] = toupper(benutzerAntwort[0]); |
||||
|
getchar(); |
||||
|
|
||||
|
if (pruefeAntwort(kategorie->fragen[i], benutzerAntwort[0])) { |
||||
|
printf("Correct!\n"); |
||||
|
punktzahl++; |
||||
|
} |
||||
|
else { |
||||
|
printf("Wrong! The correct Answer is %c\n", kategorie->fragen[i].korrekteAntwort); |
||||
|
} |
||||
|
|
||||
|
} while (0); |
||||
|
} |
||||
|
return punktzahl; |
||||
|
} |
||||
|
|
||||
|
void zeigeVerfuegbareKategorien(Kategorie kategorien[]) { |
||||
|
printf("\nChoose a Category:\n"); |
||||
|
if (kategorien[0].fragen != NULL) printf("Mountains\n"); |
||||
|
if (kategorien[1].fragen != NULL) printf("Cooking\n"); |
||||
|
if (kategorien[2].fragen != NULL) printf("Sports\n"); |
||||
|
} |
||||
|
|
||||
|
void befreieKategorie(Kategorie* kategorie) { |
||||
|
free(kategorie->fragen); |
||||
|
kategorie->fragen = NULL; |
||||
|
kategorie->anzahlFragen = 0; |
||||
|
kategorie->joker = 0; |
||||
|
} |
||||
|
|
||||
|
void quizduell() { |
||||
|
printf("Welcome to the singleplayer quizduell!\n"); |
||||
|
|
||||
|
Kategorie kategorien[MAX_CATEGORIES]; |
||||
|
kategorien[0].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage)); |
||||
|
kategorien[0].fragen[0] = erstelleFrage("Whats the height of the Zugspitze?", "2482 Meter", "2867 Meter", "2962 Meter", "3173 Meter", 'C'); |
||||
|
kategorien[0].fragen[1] = erstelleFrage("In which Federal State is the Zugspitze?", "Bayern", "Baden-Wuerttemberg", "Hessen", "Thueringen", 'A'); |
||||
|
kategorien[0].fragen[2] = erstelleFrage("Which Mountain is the highest following after the Zugspitze?", "Grossglockner", "Watzmann", "Feldberg", "Meissner", 'B'); |
||||
|
kategorien[0].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY; |
||||
|
kategorien[0].joker = 1; |
||||
|
|
||||
|
kategorien[1].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage)); |
||||
|
kategorien[1].fragen[0] = erstelleFrage("Which Ingredient is used traditionally for Pesto?", "Tomatoes", "Basil", "Spinach", "Oregano", 'B'); |
||||
|
kategorien[1].fragen[1] = erstelleFrage("Which meal is known for its usage of rice?", "Lasagna", "Sushi", "Pizza", "Hamburger", 'B'); |
||||
|
kategorien[1].fragen[2] = erstelleFrage("Which color has a ripe banana?", "Red", "Green", "Yellow", "Orange", 'C'); |
||||
|
kategorien[1].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY; |
||||
|
kategorien[1].joker = 1; |
||||
|
|
||||
|
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; |
||||
|
|
||||
|
while (1) { |
||||
|
char auswahl[50]; |
||||
|
|
||||
|
zeigeVerfuegbareKategorien(kategorien); |
||||
|
|
||||
|
printf("Your selection: "); |
||||
|
scanf("%s", auswahl); |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (auswahlIndex != -1 && kategorien[auswahlIndex].fragen != NULL) { |
||||
|
int punkte = spieleKategorie(&kategorien[auswahlIndex]); |
||||
|
printf("\nPoints in this category: %d\n", punkte); |
||||
|
|
||||
|
befreieKategorie(&kategorien[auswahlIndex]); |
||||
|
} |
||||
|
|
||||
|
else { |
||||
|
|
||||
|
printf("Invalid selection.\n"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
int verfuegbareKategorien = 0; |
||||
|
for (int i = 0; i < MAX_CATEGORIES; i++) { |
||||
|
if (kategorien[i].fragen != NULL) { |
||||
|
verfuegbareKategorien++; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (verfuegbareKategorien == 0) { |
||||
|
printf("No more available categories. Game over!\n"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
|
||||
|
} |
||||
|
} |
@ -1,6 +1,31 @@ |
|||||
#ifndef QUIZDUELL_H |
#ifndef QUIZDUELL_H |
||||
#define QUIZDUELL_H |
#define QUIZDUELL_H |
||||
|
|
||||
|
#define MAX_FRAGE_LENGTH 100 |
||||
|
#define MAX_ANTWORT_LENGTH 50 |
||||
|
#define MAX_CATEGORIES 3 |
||||
|
#define MAX_QUESTIONS_PER_CATEGORY 3 |
||||
|
|
||||
|
typedef struct { |
||||
|
char frage[MAX_FRAGE_LENGTH]; |
||||
|
char antwortA[MAX_ANTWORT_LENGTH]; |
||||
|
char antwortB[MAX_ANTWORT_LENGTH]; |
||||
|
char antwortC[MAX_ANTWORT_LENGTH]; |
||||
|
char antwortD[MAX_ANTWORT_LENGTH]; |
||||
|
char korrekteAntwort; |
||||
|
} QuizFrage; |
||||
|
|
||||
|
typedef struct { |
||||
|
QuizFrage* fragen; |
||||
|
int anzahlFragen; |
||||
|
int joker; |
||||
|
} Kategorie; |
||||
|
|
||||
|
int pruefeAntwort(QuizFrage frage, char antwort); |
||||
|
QuizFrage erstelleFrage(const char* frage, const char* antwortA, const char* antwortB, const char* antwortC, const char* antwortD, char korrekteAntwort); |
||||
|
int spieleKategorie(Kategorie* kategorie); |
||||
|
void zeigeVerfuegbareKategorien(Kategorie kategorien[]); |
||||
|
void befreieKategorie(Kategorie* kategorie); |
||||
void quizduell(); |
void quizduell(); |
||||
|
|
||||
#endif // ende QUIZDUELL_H |
#endif // ende QUIZDUELL_H |
||||
|
@ -0,0 +1,190 @@ |
|||||
|
#ifdef TEST |
||||
|
|
||||
|
#include <string.h> |
||||
|
#include <stdlib.h> |
||||
|
#include "unity.h" |
||||
|
#include "quizduell.h" |
||||
|
|
||||
|
void setUp(void) {} |
||||
|
|
||||
|
void tearDown(void) {} |
||||
|
|
||||
|
void test_erstelleFrage(void) { |
||||
|
QuizFrage testFrage = erstelleFrage("Testfrage", "AntwortA", "AntwortB", "AntwortC", "AntwortD", 'A'); |
||||
|
|
||||
|
TEST_ASSERT_EQUAL_STRING("Testfrage", testFrage.frage); |
||||
|
TEST_ASSERT_EQUAL_STRING("AntwortA", testFrage.antwortA); |
||||
|
TEST_ASSERT_EQUAL_STRING("AntwortB", testFrage.antwortB); |
||||
|
TEST_ASSERT_EQUAL_STRING("AntwortC", testFrage.antwortC); |
||||
|
TEST_ASSERT_EQUAL_STRING("AntwortD", testFrage.antwortD); |
||||
|
TEST_ASSERT_EQUAL_CHAR('A', testFrage.korrekteAntwort); |
||||
|
} |
||||
|
|
||||
|
void test_CookingFragen(void) { |
||||
|
Kategorie kategorien[MAX_CATEGORIES]; |
||||
|
|
||||
|
kategorien[1].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage)); |
||||
|
|
||||
|
kategorien[1].fragen[0] = erstelleFrage("Which Ingredient is used traditionally for Pesto?", "Tomatoes", "Basil", "Spinach", "Oregano", 'B'); |
||||
|
kategorien[1].fragen[1] = erstelleFrage("Which meal is known for its usage of rice?", "Lasagna", "Sushi", "Pizza", "Hamburger", 'B'); |
||||
|
kategorien[1].fragen[2] = erstelleFrage("Which color has a ripe banana?", "Red", "Green", "Yellow", "Orange", 'C'); |
||||
|
|
||||
|
kategorien[1].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY; |
||||
|
kategorien[1].joker = 1; |
||||
|
|
||||
|
TEST_ASSERT_EQUAL_STRING("Which Ingredient is used traditionally for Pesto?", kategorien[1].fragen[0].frage); |
||||
|
TEST_ASSERT_EQUAL_STRING("Tomatoes", kategorien[1].fragen[0].antwortA); |
||||
|
TEST_ASSERT_EQUAL_STRING("Basil", kategorien[1].fragen[0].antwortB); |
||||
|
TEST_ASSERT_EQUAL_STRING("Spinach", kategorien[1].fragen[0].antwortC); |
||||
|
TEST_ASSERT_EQUAL_STRING("Oregano", kategorien[1].fragen[0].antwortD); |
||||
|
TEST_ASSERT_EQUAL_CHAR('B', kategorien[1].fragen[0].korrekteAntwort); |
||||
|
|
||||
|
|
||||
|
free(kategorien[1].fragen); |
||||
|
} |
||||
|
void test_MountainsFragen(void) { |
||||
|
Kategorie kategorien[MAX_CATEGORIES]; |
||||
|
|
||||
|
kategorien[0].fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage)); |
||||
|
|
||||
|
kategorien[0].fragen[0] = erstelleFrage("Whats the height of the Zugspitze?", "2482 Meter", "2867 Meter", "2962 Meter", "3173 Meter", 'C'); |
||||
|
kategorien[0].fragen[1] = erstelleFrage("In which Federal State is the Zugspitze?", "Bayern", "Baden-Wuerttemberg", "Hessen", "Thueringen", 'A'); |
||||
|
kategorien[0].fragen[2] = erstelleFrage("Which Mountain is the highest following after the Zugspitze?", "Grossglockner", "Watzmann", "Feldberg", "Meissner", 'B'); |
||||
|
|
||||
|
kategorien[0].anzahlFragen = MAX_QUESTIONS_PER_CATEGORY; |
||||
|
kategorien[0].joker = 1; |
||||
|
|
||||
|
TEST_ASSERT_EQUAL_STRING("Whats the height of the Zugspitze?", kategorien[0].fragen[0].frage); |
||||
|
TEST_ASSERT_EQUAL_STRING("2482 Meter", kategorien[0].fragen[0].antwortA); |
||||
|
TEST_ASSERT_EQUAL_STRING("2867 Meter", kategorien[0].fragen[0].antwortB); |
||||
|
TEST_ASSERT_EQUAL_STRING("2962 Meter", kategorien[0].fragen[0].antwortC); |
||||
|
TEST_ASSERT_EQUAL_STRING("3173 Meter", kategorien[0].fragen[0].antwortD); |
||||
|
TEST_ASSERT_EQUAL_CHAR('C', kategorien[0].fragen[0].korrekteAntwort); |
||||
|
|
||||
|
free(kategorien[0].fragen); |
||||
|
} |
||||
|
void test_createCategory2WithQuestions(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_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_CHAR('B', kategorien[2].fragen[0].korrekteAntwort); |
||||
|
|
||||
|
free(kategorien[2].fragen); |
||||
|
} |
||||
|
void test_befreieKategorie(void) { |
||||
|
Kategorie testKategorie; |
||||
|
testKategorie.fragen = (QuizFrage*)malloc(MAX_QUESTIONS_PER_CATEGORY * sizeof(QuizFrage)); |
||||
|
testKategorie.anzahlFragen = 3; |
||||
|
testKategorie.joker = 1; |
||||
|
|
||||
|
befreieKategorie(&testKategorie); |
||||
|
|
||||
|
TEST_ASSERT_NULL(testKategorie.fragen); |
||||
|
TEST_ASSERT_EQUAL_INT(0, testKategorie.anzahlFragen); |
||||
|
TEST_ASSERT_EQUAL_INT(0, testKategorie.joker); |
||||
|
} |
||||
|
void test_pruefeAntwort_CorrectAnswer(void) { |
||||
|
QuizFrage frage = erstelleFrage("Test Question", "Option A", "Option B", "Option C", "Option D", 'A'); |
||||
|
TEST_ASSERT_EQUAL_INT(1, pruefeAntwort(frage, 'A')); |
||||
|
} |
||||
|
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; |
||||
|
} |
||||
|
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); |
||||
|
} |
||||
|
void test_categorySelection_Sports(void) { |
||||
|
Kategorie kategorien[MAX_CATEGORIES]; |
||||
|
|
||||
|
char auswahl[50] = "Sports"; |
||||
|
|
||||
|
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(2, auswahlIndex); |
||||
|
} |
||||
|
#endif //TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue