#ifdef TEST #include #include #include "unity.h" #include "casualQuiz.h" // Test setup function void setUp(void) { } // Test teardown function void tearDown(void) { } void test_FcheckaufRichtigkeit_correct_answer_atIndex1(void){ int TESTeingabe = 1; int TESTindex = 0; int TESTrichtige_antwort[]={1}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall == true); } void test_FcheckaufRichtigkeit_correct_answer_atIndex2(void){ int TESTeingabe = 2; int TESTindex = 0; int TESTrichtige_antwort[]={2}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall == true); } void test_FcheckaufRichtigkeit_correct_answer_atIndex3(void){ int TESTeingabe = 3; int TESTindex = 0; int TESTrichtige_antwort[]={3}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall == true); }void test_FcheckaufRichtigkeit_correct_answer_atIndex4(void){ int TESTeingabe = 4; int TESTindex = 0; int TESTrichtige_antwort[]={4}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall == true); } void test_FcheckaufRichtigkeit_incorrect_input_higher(void){ int TESTeingabe = 5; int TESTindex = 0; int TESTrichtige_antwort[]={3}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall != true); } void test_FcheckaufRichtigkeit_incorrect_input_lower(void){ int TESTeingabe = -1; int TESTindex = 0; int TESTrichtige_antwort[]={3}; bool testfall; char* TESTantworten[]= {"The End", "The Termination", "Pizza's ready", "Hotdog Time"}; testfall = fcheckaufRichtigkeit(TESTeingabe, TESTantworten, TESTrichtige_antwort, TESTindex); TEST_ASSERT_TRUE(testfall != true); } void test_FzaehlernachAuswahl(void){ bool richtig = true; int correct = 0; int answered = 0; int* correctP = &correct; int* answeredP = &answered; fzaehlernachAuswahl(richtig, answeredP, correctP); TEST_ASSERT_EQUAL_INT(1, correct); TEST_ASSERT_EQUAL_INT(1, answered); } void test_FzaehlernachAuswahl_bei1(void){ bool richtig = true; int correct = 1; int answered = 1; int* correctP = &correct; int* answeredP = &answered; fzaehlernachAuswahl(richtig, answeredP, correctP); TEST_ASSERT_EQUAL_INT(2, correct); TEST_ASSERT_EQUAL_INT(2, answered); } void test_FzaehlernachAuswahl_falsch_bei_0(void){ bool richtig = false; int correct = 0; int answered = 0; int* correctP = &correct; int* answeredP = &answered; fzaehlernachAuswahl(richtig, answeredP, correctP); TEST_ASSERT_EQUAL_INT(0, correct); TEST_ASSERT_EQUAL_INT(1, answered); } void test_FzaehlernachAuswahl_falsch_bei_1(void){ bool richtig = false; int correct = 1; int answered = 1; int* correctP = &correct; int* answeredP = &answered; fzaehlernachAuswahl(richtig, answeredP, correctP); TEST_ASSERT_EQUAL_INT(1, correct); TEST_ASSERT_EQUAL_INT(2, answered); } void test_FtryAgain_butalways_played_is_false(void){ bool already_played = false; bool testbool = true; testbool = ftryAgain(already_played); TEST_ASSERT_TRUE(testbool == false); } #endif //Test