Florian Baeseler
11 months ago
5 changed files with 250 additions and 68 deletions
-
1build/test/dependencies/casualQuiz.d
-
BINbuild/test/out/c/casualQuiz.o
-
112src/casualQuiz.c
-
4src/casualQuiz.h
-
121test/test_casualQuiz.c
@ -0,0 +1 @@ |
|||
build/test/out/c/casualQuiz.o: src/casualQuiz.c src/casualQuiz.h |
@ -0,0 +1,121 @@ |
|||
#ifdef TEST |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdio.h> |
|||
#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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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; |
|||
testfall = FcheckaufRichtigkeit(TESTeingabe, 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); |
|||
|
|||
} |
|||
#endif //Test |
Write
Preview
Loading…
Cancel
Save
Reference in new issue