Browse Source

refactoring: frage auf ausgabe der richtigen antwort ausgelagert in fceckaufRichtigkeit() Funktion, dadurch schleife besser lesbar

remotes/origin/Florian
Florian Baeseler 11 months ago
parent
commit
543f6173fb
  1. 54
      build/test/cache/test_casualQuiz.c
  2. BIN
      build/test/out/c/casualQuiz.o
  3. BIN
      build/test/out/c/test_casualQuiz.o
  4. BIN
      build/test/out/c/test_casualQuiz_runner.o
  5. BIN
      build/test/out/test_casualQuiz.out
  6. 54
      build/test/preprocess/files/test_casualQuiz.c
  7. 22
      build/test/results/test_casualQuiz.pass
  8. 2
      build/test/results/test_quizduell.pass
  9. 2
      build/test/results/test_timequiz.pass
  10. 2
      build/test/results/test_wwm.pass
  11. 20
      build/test/runners/test_casualQuiz_runner.c
  12. 44
      src/casualQuiz.c
  13. 2
      src/casualQuiz.h
  14. 18
      test/test_casualQuiz.c

54
build/test/cache/test_casualQuiz.c

@ -40,7 +40,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -48,7 +50,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(25)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(26)));}} while(0);
@ -68,7 +70,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -76,7 +80,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(35)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(37)));}} while(0);
@ -96,7 +100,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -104,7 +110,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(45)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(48)));}} while(0);
@ -122,7 +128,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -130,7 +138,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(54)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(58)));}} while(0);
@ -150,13 +158,15 @@ void test_FcheckaufRichtigkeit_incorrect_input_higher(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
do {if ((testfall != do {if ((testfall !=
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(63)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(68)));}} while(0);
} }
@ -174,13 +184,15 @@ void test_FcheckaufRichtigkeit_incorrect_input_lower(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
do {if ((testfall != do {if ((testfall !=
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(71)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(77)));}} while(0);
} }
@ -212,13 +224,13 @@ void test_FzaehlernachAuswahl(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(81), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(87), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT);
@ -252,13 +264,13 @@ void test_FzaehlernachAuswahl_bei1(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(93), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(99), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(100), UNITY_DISPLAY_STYLE_INT);
@ -292,13 +304,13 @@ void test_FzaehlernachAuswahl_falsch_bei_0(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(105), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(111), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(106), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(112), UNITY_DISPLAY_STYLE_INT);
@ -332,13 +344,13 @@ void test_FzaehlernachAuswahl_falsch_bei_1(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(117), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(123), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(118), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(124), UNITY_DISPLAY_STYLE_INT);
@ -374,7 +386,7 @@ do {if ((testbool ==
0 0
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(126)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(132)));}} while(0);

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

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

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

BIN
build/test/out/test_casualQuiz.out

54
build/test/preprocess/files/test_casualQuiz.c

@ -40,7 +40,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -48,7 +50,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(25)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(26)));}} while(0);
@ -68,7 +70,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -76,7 +80,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(35)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(37)));}} while(0);
@ -96,7 +100,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -104,7 +110,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(45)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(48)));}} while(0);
@ -122,7 +128,9 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
@ -130,7 +138,7 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(54)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(58)));}} while(0);
@ -150,13 +158,15 @@ void test_FcheckaufRichtigkeit_incorrect_input_higher(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
do {if ((testfall != do {if ((testfall !=
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(63)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(68)));}} while(0);
} }
@ -174,13 +184,15 @@ void test_FcheckaufRichtigkeit_incorrect_input_lower(void){
testfall; testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
do {if ((testfall != do {if ((testfall !=
1 1
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(71)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(77)));}} while(0);
} }
@ -212,13 +224,13 @@ void test_FzaehlernachAuswahl(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(81), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(87), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT);
@ -252,13 +264,13 @@ void test_FzaehlernachAuswahl_bei1(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(93), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(99), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(100), UNITY_DISPLAY_STYLE_INT);
@ -292,13 +304,13 @@ void test_FzaehlernachAuswahl_falsch_bei_0(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(105), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(111), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(106), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(112), UNITY_DISPLAY_STYLE_INT);
@ -332,13 +344,13 @@ void test_FzaehlernachAuswahl_falsch_bei_1(void){
((void *)0) ((void *)0)
), (UNITY_UINT)(117), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(123), UNITY_DISPLAY_STYLE_INT);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), ( UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((answered)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(118), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(124), UNITY_DISPLAY_STYLE_INT);
@ -374,7 +386,7 @@ do {if ((testbool ==
0 0
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(126)));}} while(0);
)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(132)));}} while(0);

22
build/test/results/test_casualQuiz.pass

@ -8,43 +8,43 @@
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FcheckaufRichtigkeit_correct_answer_atIndex2 - :test: test_FcheckaufRichtigkeit_correct_answer_atIndex2
:line: 28
:line: 29
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FcheckaufRichtigkeit_correct_answer_atIndex3 - :test: test_FcheckaufRichtigkeit_correct_answer_atIndex3
:line: 38
:line: 40
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FcheckaufRichtigkeit_correct_answer_atIndex4 - :test: test_FcheckaufRichtigkeit_correct_answer_atIndex4
:line: 47
:line: 50
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FcheckaufRichtigkeit_incorrect_input_higher - :test: test_FcheckaufRichtigkeit_incorrect_input_higher
:line: 57
:line: 61
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FcheckaufRichtigkeit_incorrect_input_lower - :test: test_FcheckaufRichtigkeit_incorrect_input_lower
:line: 65
:line: 70
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FzaehlernachAuswahl - :test: test_FzaehlernachAuswahl
:line: 73
:line: 79
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FzaehlernachAuswahl_bei1 - :test: test_FzaehlernachAuswahl_bei1
:line: 85
:line: 91
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FzaehlernachAuswahl_falsch_bei_0 - :test: test_FzaehlernachAuswahl_falsch_bei_0
:line: 97
:line: 103
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FzaehlernachAuswahl_falsch_bei_1 - :test: test_FzaehlernachAuswahl_falsch_bei_1
:line: 109
:line: 115
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_FtryAgain_butalways_played_is_false - :test: test_FtryAgain_butalways_played_is_false
:line: 121
:line: 127
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
:failures: [] :failures: []
@ -66,4 +66,4 @@
- Wrong Input! - Wrong Input!
- Wrong Input! - Wrong Input!
- It looks like you havent played the program yet, starting it up... - It looks like you havent played the program yet, starting it up...
:time: 0.03676419996190816
:time: 0.015266000060364604

2
build/test/results/test_quizduell.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.014482000027783215
:time: 0.014835100038908422

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.015876200050115585
:time: 0.013974100002087653

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.016650600009597838
:time: 0.015707500046119094

20
build/test/runners/test_casualQuiz_runner.c

@ -86,16 +86,16 @@ int main(void)
{ {
UnityBegin("test_casualQuiz.c"); UnityBegin("test_casualQuiz.c");
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex1, "test_FcheckaufRichtigkeit_correct_answer_atIndex1", 18); run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex1, "test_FcheckaufRichtigkeit_correct_answer_atIndex1", 18);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex2, "test_FcheckaufRichtigkeit_correct_answer_atIndex2", 28);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex3, "test_FcheckaufRichtigkeit_correct_answer_atIndex3", 38);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex4, "test_FcheckaufRichtigkeit_correct_answer_atIndex4", 47);
run_test(test_FcheckaufRichtigkeit_incorrect_input_higher, "test_FcheckaufRichtigkeit_incorrect_input_higher", 57);
run_test(test_FcheckaufRichtigkeit_incorrect_input_lower, "test_FcheckaufRichtigkeit_incorrect_input_lower", 65);
run_test(test_FzaehlernachAuswahl, "test_FzaehlernachAuswahl", 73);
run_test(test_FzaehlernachAuswahl_bei1, "test_FzaehlernachAuswahl_bei1", 85);
run_test(test_FzaehlernachAuswahl_falsch_bei_0, "test_FzaehlernachAuswahl_falsch_bei_0", 97);
run_test(test_FzaehlernachAuswahl_falsch_bei_1, "test_FzaehlernachAuswahl_falsch_bei_1", 109);
run_test(test_FtryAgain_butalways_played_is_false, "test_FtryAgain_butalways_played_is_false", 121);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex2, "test_FcheckaufRichtigkeit_correct_answer_atIndex2", 29);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex3, "test_FcheckaufRichtigkeit_correct_answer_atIndex3", 40);
run_test(test_FcheckaufRichtigkeit_correct_answer_atIndex4, "test_FcheckaufRichtigkeit_correct_answer_atIndex4", 50);
run_test(test_FcheckaufRichtigkeit_incorrect_input_higher, "test_FcheckaufRichtigkeit_incorrect_input_higher", 61);
run_test(test_FcheckaufRichtigkeit_incorrect_input_lower, "test_FcheckaufRichtigkeit_incorrect_input_lower", 70);
run_test(test_FzaehlernachAuswahl, "test_FzaehlernachAuswahl", 79);
run_test(test_FzaehlernachAuswahl_bei1, "test_FzaehlernachAuswahl_bei1", 91);
run_test(test_FzaehlernachAuswahl_falsch_bei_0, "test_FzaehlernachAuswahl_falsch_bei_0", 103);
run_test(test_FzaehlernachAuswahl_falsch_bei_1, "test_FzaehlernachAuswahl_falsch_bei_1", 115);
run_test(test_FtryAgain_butalways_played_is_false, "test_FtryAgain_butalways_played_is_false", 127);
return UnityEnd(); return UnityEnd();
} }

44
src/casualQuiz.c

@ -76,14 +76,9 @@ bool activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], in
fzeigeAntworten(antworten, i); //Antworten zum gleichen index wie die fragen ausgeben fzeigeAntworten(antworten, i); //Antworten zum gleichen index wie die fragen ausgeben
printf("Reminder: Typing 0 lets you stop the game.\nPlease type in your answer 1,2,3 or 4: "); printf("Reminder: Typing 0 lets you stop the game.\nPlease type in your answer 1,2,3 or 4: ");
eingabe = feingabeInteger(); //eingabe Funktion eingabe = feingabeInteger(); //eingabe Funktion
richtig = fcheckaufRichtigkeit(eingabe, richtige_antwort, i); //überprüfung der eingabe anhand des richtige_eingabe arrays und dem index
richtig = fcheckaufRichtigkeit(eingabe, antworten, richtige_antwort, i); //überprüfung der eingabe anhand des richtige_eingabe arrays und dem index
fzaehlernachAuswahl(richtig, answeredP, correctP); // zähler werden hochgezählt je nach eingabe fzaehlernachAuswahl(richtig, answeredP, correctP); // zähler werden hochgezählt je nach eingabe
if (richtig == false){
printf("Would you like to know the right answer?\nInput 1 if oyu want to see it, 0 if not: ");
scanf_s("%d", &ansehen);
if (ansehen == 1) printf("The right answer was: %d) %s\n", richtige_antwort[i],antworten[4 * i + richtige_antwort[i-1]]);
else printf("Continuing...\n");
}
} }
return true; return true;
@ -102,7 +97,8 @@ int feingabeInteger() {
scanf_s("%d", &eingabe); //reine ingabe, prints sind vorher schon passiert scanf_s("%d", &eingabe); //reine ingabe, prints sind vorher schon passiert
return eingabe; // return der eingabe return eingabe; // return der eingabe
} }
bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
bool fcheckaufRichtigkeit(int eingabe,char* antworten[], int richtige_antwort[], int i) {
int ansehen = 0;
switch (eingabe) {//start vom switch switch (eingabe) {//start vom switch
case 0:{ //eingabe 0: abbruch funktion wird aufgerufen case 0:{ //eingabe 0: abbruch funktion wird aufgerufen
fabbruch(); fabbruch();
@ -114,7 +110,13 @@ bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
printf("Right Answer, well done.\n"); printf("Right Answer, well done.\n");
return true; return true;
} }
else printf("Wrong answer.\n"); //wenn eingabe falsch ist
else {
printf("Wrong answer.\n"); //wenn eingabe falsch ist
printf("Would you like to know the right answer?\nInput 1 if oyu want to see it, 0 if not: ");
scanf_s("%d", &ansehen);
if (ansehen == 1) printf("The right answer was: %d) %s\n", richtige_antwort[i],antworten[4 * i + richtige_antwort[i]-1]);
else printf("Continuing...\n");
}
break; break;
} }
case 2: { case 2: {
@ -123,7 +125,13 @@ bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
printf("Right Answer, well done.\n"); printf("Right Answer, well done.\n");
return true; return true;
} }
else printf("Wrong answer.\n");//wenn eingabe falsch ist
else {
printf("Wrong answer.\n"); //wenn eingabe falsch ist
printf("Would you like to know the right answer?\nInput 1 if oyu want to see it, 0 if not: ");
scanf_s("%d", &ansehen);
if (ansehen == 1) printf("The right answer was: %d) %s\n", richtige_antwort[i],antworten[4 * i + richtige_antwort[i]-1]);
else printf("Continuing...\n");
}
break; break;
} }
case 3: { case 3: {
@ -132,7 +140,13 @@ bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
printf("Right Answer, well done.\n"); printf("Right Answer, well done.\n");
return true; return true;
} }
else printf("Wrong answer.\n");//wenn eingabe falsch ist
else {
printf("Wrong answer.\n"); //wenn eingabe falsch ist
printf("Would you like to know the right answer?\nInput 1 if oyu want to see it, 0 if not: ");
scanf_s("%d", &ansehen);
if (ansehen == 1) printf("The right answer was: %d) %s\n", richtige_antwort[i],antworten[4 * i + richtige_antwort[i]-1]);
else printf("Continuing...\n");
}
break; break;
} }
case 4: { case 4: {
@ -141,7 +155,13 @@ bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i) {
printf("Right Answer, well done.\n"); printf("Right Answer, well done.\n");
return true; return true;
} }
else printf("Wrong answer.\n");// wenn eingabe falsch ist
else {
printf("Wrong answer.\n"); //wenn eingabe falsch ist
printf("Would you like to know the right answer?\nInput 1 if oyu want to see it, 0 if not: ");
scanf_s("%d", &ansehen);
if (ansehen == 1) printf("The right answer was: %d) %s\n", richtige_antwort[i],antworten[4 * i + richtige_antwort[i]-1]);
else printf("Continuing...\n");
}
break; break;
} }
default: { // eingabe war was anderes als 1,2,3,4 oder 5 default: { // eingabe war was anderes als 1,2,3,4 oder 5

2
src/casualQuiz.h

@ -6,7 +6,7 @@ bool activePlaying(char* fragen[], char* antworten[], int richtige_antwort[], in
void fzeigeFragen(char* fragen[], int index); void fzeigeFragen(char* fragen[], int index);
void fzeigeAntworten(char* antworten[], int index); void fzeigeAntworten(char* antworten[], int index);
int feingabeInteger(); int feingabeInteger();
bool fcheckaufRichtigkeit(int eingabe, int richtige_antwort[], int i);
bool fcheckaufRichtigkeit(int eingabe,char* antworten[], int richtige_antwort[], int i);
void fzaehlernachAuswahl(bool richtig, int* answeredP, int* correctP); void fzaehlernachAuswahl(bool richtig, int* answeredP, int* correctP);
bool ftryAgain(bool already_played); bool ftryAgain(bool already_played);
void fabbruch(); void fabbruch();

18
test/test_casualQuiz.c

@ -20,7 +20,8 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={1}; int TESTrichtige_antwort[]={1};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall == true); TEST_ASSERT_TRUE(testfall == true);
@ -30,7 +31,8 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={2}; int TESTrichtige_antwort[]={2};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall == true); TEST_ASSERT_TRUE(testfall == true);
@ -40,7 +42,8 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={3}; int TESTrichtige_antwort[]={3};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall == true); TEST_ASSERT_TRUE(testfall == true);
@ -49,7 +52,8 @@ void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={4}; int TESTrichtige_antwort[]={4};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall == true); TEST_ASSERT_TRUE(testfall == true);
@ -59,7 +63,8 @@ void test_FcheckaufRichtigkeit_incorrect_input_higher(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={3}; int TESTrichtige_antwort[]={3};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall != true); TEST_ASSERT_TRUE(testfall != true);
} }
void test_FcheckaufRichtigkeit_incorrect_input_lower(void){ void test_FcheckaufRichtigkeit_incorrect_input_lower(void){
@ -67,7 +72,8 @@ void test_FcheckaufRichtigkeit_incorrect_input_lower(void){
int TESTindex = 0; int TESTindex = 0;
int TESTrichtige_antwort[]={3}; int TESTrichtige_antwort[]={3};
bool testfall; bool testfall;
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTrichtige_antwort, TESTindex);
char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"};
testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex);
TEST_ASSERT_TRUE(testfall != true); TEST_ASSERT_TRUE(testfall != true);
} }
void test_FzaehlernachAuswahl(void){ void test_FzaehlernachAuswahl(void){

Loading…
Cancel
Save