You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.1 KiB
121 lines
3.1 KiB
#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
|