Browse Source

Merge branch 'Kevin' into 'main'

Kevin

See merge request fdai7760/the-quizstars!1
main
fdai8033 11 months ago
parent
commit
27c6f889ab
  1. 4
      build/test/cache/defines_dependency.yml
  2. 22
      build/test/cache/input.yml
  3. 543
      build/test/cache/test_quizduell.c
  4. 10
      build/test/dependencies/cmock.d
  5. 0
      build/test/dependencies/force_build
  6. 1
      build/test/dependencies/quizduell.d
  7. 4
      build/test/dependencies/test_casualQuiz_runner.d
  8. 5
      build/test/dependencies/test_quizduell.d
  9. 4
      build/test/dependencies/test_quizduell_runner.d
  10. 4
      build/test/dependencies/test_timequiz_runner.d
  11. 4
      build/test/dependencies/test_wwm_runner.d
  12. 6
      build/test/dependencies/unity.d
  13. BIN
      build/test/out/c/cmock.o
  14. BIN
      build/test/out/c/quizduell.o
  15. BIN
      build/test/out/c/test_casualQuiz.o
  16. BIN
      build/test/out/c/test_casualQuiz_runner.o
  17. BIN
      build/test/out/c/test_quizduell.o
  18. BIN
      build/test/out/c/test_quizduell_runner.o
  19. BIN
      build/test/out/c/test_timequiz.o
  20. BIN
      build/test/out/c/test_timequiz_runner.o
  21. BIN
      build/test/out/c/test_wwm.o
  22. BIN
      build/test/out/c/test_wwm_runner.o
  23. BIN
      build/test/out/c/unity.o
  24. BIN
      build/test/out/test_casualQuiz.out
  25. BIN
      build/test/out/test_quizduell.out
  26. BIN
      build/test/out/test_timequiz.out
  27. BIN
      build/test/out/test_wwm.out
  28. 543
      build/test/preprocess/files/test_quizduell.c
  29. 4
      build/test/preprocess/includes/test_quizduell.c
  30. 2
      build/test/results/test_casualQuiz.pass
  31. 44
      build/test/results/test_quizduell.pass
  32. 2
      build/test/results/test_timequiz.pass
  33. 2
      build/test/results/test_wwm.pass
  34. 52
      build/test/runners/test_quizduell_runner.c
  35. 206
      src/quizduell.c
  36. 25
      src/quizduell.h
  37. 190
      test/test_quizduell.c

4
build/test/cache/defines_dependency.yml

@ -1 +1,3 @@
--- {}
---
src/quizduell.c:
- TEST

22
build/test/cache/input.yml

@ -77,10 +77,10 @@
:testfail: ".fail" :testfail: ".fail"
:dependencies: ".d" :dependencies: ".d"
:unity: :unity:
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: [] :defines: []
:cmock: :cmock:
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: [] :defines: []
:includes: [] :includes: []
:mock_prefix: mock_ :mock_prefix: mock_
@ -99,14 +99,14 @@
:verbosity: 3 :verbosity: 3
:unity_helper: false :unity_helper: false
:cexception: :cexception:
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: [] :defines: []
:test_runner: :test_runner:
:includes: [] :includes: []
:file_suffix: _runner :file_suffix: _runner
:tools: :tools:
:test_compiler: :test_compiler:
:executable: gcc
:executable: gcc.exe
:name: default_test_compiler :name: default_test_compiler
:stderr_redirect: :none :stderr_redirect: :none
:background_exec: :none :background_exec: :none
@ -132,7 +132,7 @@
:optional: false :optional: false
:arguments: [] :arguments: []
:test_linker: :test_linker:
:executable: gcc
:executable: gcc.exe
:name: default_test_linker :name: default_test_linker
:stderr_redirect: :none :stderr_redirect: :none
:background_exec: :none :background_exec: :none
@ -148,7 +148,7 @@
- "${4}" - "${4}"
- '' - ''
:test_file_preprocessor: :test_file_preprocessor:
:executable: gcc
:executable: gcc.exe
:name: default_test_file_preprocessor :name: default_test_file_preprocessor
:stderr_redirect: :none :stderr_redirect: :none
:background_exec: :none :background_exec: :none
@ -165,7 +165,7 @@
- '"${1}"' - '"${1}"'
- -o "${2}" - -o "${2}"
:test_file_preprocessor_directives: :test_file_preprocessor_directives:
:executable: gcc
:executable: gcc.exe
:name: default_test_file_preprocessor_directives :name: default_test_file_preprocessor_directives
:stderr_redirect: :none :stderr_redirect: :none
:background_exec: :none :background_exec: :none
@ -181,7 +181,7 @@
- '"${1}"' - '"${1}"'
- -o "${2}" - -o "${2}"
:test_includes_preprocessor: :test_includes_preprocessor:
:executable: gcc
:executable: gcc.exe
:name: default_test_includes_preprocessor :name: default_test_includes_preprocessor
:stderr_redirect: :none :stderr_redirect: :none
:background_exec: :none :background_exec: :none
@ -223,13 +223,13 @@
:arguments: [] :arguments: []
:plugins: :plugins:
:load_paths: :load_paths:
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins"
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins
:enabled: :enabled:
- stdout_pretty_tests_report - stdout_pretty_tests_report
- module_generator - module_generator
:display_raw_test_results: false :display_raw_test_results: false
:stdout_pretty_tests_report_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report"
:module_generator_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator"
:stdout_pretty_tests_report_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report
:module_generator_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator
:gcov: :gcov:
:reports: :reports:
- HtmlDetailed - HtmlDetailed

543
build/test/cache/test_quizduell.c

@ -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);
}

10
build/test/dependencies/cmock.d

@ -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
build/test/dependencies/force_build

1
build/test/dependencies/quizduell.d

@ -0,0 +1 @@
build/test/out/c/quizduell.o: src/quizduell.c src/quizduell.h

4
build/test/dependencies/test_casualQuiz_runner.d

@ -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

5
build/test/dependencies/test_quizduell.d

@ -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

4
build/test/dependencies/test_quizduell_runner.d

@ -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

4
build/test/dependencies/test_timequiz_runner.d

@ -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

4
build/test/dependencies/test_wwm_runner.d

@ -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

6
build/test/dependencies/unity.d

@ -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

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

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

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

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

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

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

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

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

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

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

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

BIN
build/test/out/test_casualQuiz.out

BIN
build/test/out/test_quizduell.out

BIN
build/test/out/test_timequiz.out

BIN
build/test/out/test_wwm.out

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

@ -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);
}

4
build/test/preprocess/includes/test_quizduell.c

@ -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

2
build/test/results/test_casualQuiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.004336156009230763
:time: 0.016197599999941303

44
build/test/results/test_quizduell.pass

@ -2,13 +2,49 @@
:source: :source:
:path: test :path: test
:file: test_quizduell.c :file: test_quizduell.c
:successes: []
:successes:
- :test: test_erstelleFrage
:line: 12
:message: ''
:unity_test_time: 0
- :test: test_CookingFragen
:line: 23
:message: ''
:unity_test_time: 0
- :test: test_MountainsFragen
:line: 45
:message: ''
:unity_test_time: 0
- :test: test_createCategory2WithQuestions
:line: 66
:message: ''
:unity_test_time: 0
- :test: test_befreieKategorie
:line: 87
:message: ''
:unity_test_time: 0
- :test: test_pruefeAntwort_CorrectAnswer
:line: 99
:message: ''
:unity_test_time: 0
- :test: test_pruefeAntwort_WrongAnswer
:line: 103
:message: ''
:unity_test_time: 0
- :test: test_sportsCategoryInitialization
:line: 107
:message: ''
:unity_test_time: 0
- :test: test_categorySelection_Cooking
:line: 143
:message: ''
:unity_test_time: 0
:failures: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 0
:passed: 0
:total: 9
:passed: 9
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.004334530996857211
:time: 0.03187939999952505

2
build/test/results/test_timequiz.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0043847519846167415
:time: 0.016576800000621006

2
build/test/results/test_wwm.pass

@ -11,4 +11,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.004366140026831999
:time: 0.016380900000513066

52
build/test/runners/test_quizduell_runner.c

@ -10,6 +10,15 @@ char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/ /*=======External Functions This Runner Calls=====*/
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_erstelleFrage(void);
extern void test_CookingFragen(void);
extern void test_MountainsFragen(void);
extern void test_createCategory2WithQuestions(void);
extern void test_befreieKategorie(void);
extern void test_pruefeAntwort_CorrectAnswer(void);
extern void test_pruefeAntwort_WrongAnswer(void);
extern void test_sportsCategoryInitialization(void);
extern void test_categorySelection_Cooking(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -26,12 +35,6 @@ static void CMock_Destroy(void)
{ {
} }
/*=======Setup (stub)=====*/
void setUp(void) {}
/*=======Teardown (stub)=====*/
void tearDown(void) {}
/*=======Test Reset Options=====*/ /*=======Test Reset Options=====*/
void resetTest(void); void resetTest(void);
void resetTest(void) void resetTest(void)
@ -48,10 +51,47 @@ void verifyTest(void)
CMock_Verify(); CMock_Verify();
} }
/*=======Test Runner Used To Run Each Test=====*/
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)
{
Unity.CurrentTestName = name;
Unity.CurrentTestLineNumber = line_num;
#ifdef UNITY_USE_COMMAND_LINE_ARGS
if (!UnityTestMatches())
return;
#endif
Unity.NumberOfTests++;
UNITY_CLR_DETAILS();
UNITY_EXEC_TIME_START();
CMock_Init();
if (TEST_PROTECT())
{
setUp();
func();
}
if (TEST_PROTECT())
{
tearDown();
CMock_Verify();
}
CMock_Destroy();
UNITY_EXEC_TIME_STOP();
UnityConcludeTest();
}
/*=======MAIN=====*/ /*=======MAIN=====*/
int main(void) int main(void)
{ {
UnityBegin("test_quizduell.c"); UnityBegin("test_quizduell.c");
run_test(test_erstelleFrage, "test_erstelleFrage", 12);
run_test(test_CookingFragen, "test_CookingFragen", 23);
run_test(test_MountainsFragen, "test_MountainsFragen", 45);
run_test(test_createCategory2WithQuestions, "test_createCategory2WithQuestions", 66);
run_test(test_befreieKategorie, "test_befreieKategorie", 87);
run_test(test_pruefeAntwort_CorrectAnswer, "test_pruefeAntwort_CorrectAnswer", 99);
run_test(test_pruefeAntwort_WrongAnswer, "test_pruefeAntwort_WrongAnswer", 103);
run_test(test_sportsCategoryInitialization, "test_sportsCategoryInitialization", 107);
run_test(test_categorySelection_Cooking, "test_categorySelection_Cooking", 143);
return UnityEnd(); return UnityEnd();
} }

206
src/quizduell.c

@ -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;
}
}

25
src/quizduell.h

@ -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

190
test/test_quizduell.c

@ -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
Loading…
Cancel
Save