Browse Source

Unittest9

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

222
build/test/cache/test_quizduell.c

@ -319,3 +319,225 @@ void test_pruefeAntwort_WrongAnswer(void) {
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); ), (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);
}

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

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

BIN
build/test/out/test_quizduell.out

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

@ -319,3 +319,225 @@ void test_pruefeAntwort_WrongAnswer(void) {
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); ), (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);
}

2
build/test/results/test_casualQuiz.pass

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

14
build/test/results/test_quizduell.pass

@ -31,12 +31,20 @@
:line: 102 :line: 102
:message: '' :message: ''
:unity_test_time: 0 :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: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 7
:passed: 7
:total: 9
:passed: 9
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.01651020000099379
:time: 0.0320902000003116

2
build/test/results/test_timequiz.pass

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

2
build/test/results/test_wwm.pass

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

4
build/test/runners/test_quizduell_runner.c

@ -17,6 +17,8 @@ extern void test_createCategory2WithQuestions(void);
extern void test_befreieKategorie(void); extern void test_befreieKategorie(void);
extern void test_pruefeAntwort_CorrectAnswer(void); extern void test_pruefeAntwort_CorrectAnswer(void);
extern void test_pruefeAntwort_WrongAnswer(void); extern void test_pruefeAntwort_WrongAnswer(void);
extern void test_sportsCategoryInitialization(void);
extern void test_categorySelection_Cooking(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -88,6 +90,8 @@ int main(void)
run_test(test_befreieKategorie, "test_befreieKategorie", 86); run_test(test_befreieKategorie, "test_befreieKategorie", 86);
run_test(test_pruefeAntwort_CorrectAnswer, "test_pruefeAntwort_CorrectAnswer", 98); run_test(test_pruefeAntwort_CorrectAnswer, "test_pruefeAntwort_CorrectAnswer", 98);
run_test(test_pruefeAntwort_WrongAnswer, "test_pruefeAntwort_WrongAnswer", 102); 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(); return UnityEnd();
} }

24
test/test_quizduell.c

@ -1,5 +1,6 @@
#ifdef TEST #ifdef TEST
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "unity.h" #include "unity.h"
#include "quizduell.h" #include "quizduell.h"
@ -139,4 +140,27 @@ void test_sportsCategoryInitialization(void) {
free(kategorien[2].fragen); free(kategorien[2].fragen);
kategorien[2].fragen = NULL; 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 #endif //TEST
Loading…
Cancel
Save