|
@ -8,17 +8,17 @@ void setUp(void) { |
|
|
|
|
|
|
|
|
void tearDown(void) { |
|
|
void tearDown(void) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob richtger Index rausgegeben wird |
|
|
void test_getRandomQuestionIndex(void) { |
|
|
void test_getRandomQuestionIndex(void) { |
|
|
int askedQuestions[10] = {0}; |
|
|
int askedQuestions[10] = {0}; |
|
|
int totalQuestions = 10; |
|
|
int totalQuestions = 10; |
|
|
int index = getRandomQuestionIndex(askedQuestions, totalQuestions); |
|
|
int index = getRandomQuestionIndex(askedQuestions, totalQuestions); |
|
|
TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions); |
|
|
TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob die Fragen richtig angezeigt werden |
|
|
void test_displayQuestion(void) { |
|
|
void test_displayQuestion(void) { |
|
|
char* question = "Test Question"; |
|
|
|
|
|
char* answers[] = {"A", "B", "C", "D"}; |
|
|
|
|
|
|
|
|
const char* question = "Test Question"; |
|
|
|
|
|
const char* answers[] = {"A", "B", "C", "D"}; |
|
|
int correctIndex = 0; |
|
|
int correctIndex = 0; |
|
|
printf("\nExpected Output:\n"); |
|
|
printf("\nExpected Output:\n"); |
|
|
printf("Question: %s\n", question); |
|
|
printf("Question: %s\n", question); |
|
@ -29,11 +29,11 @@ void test_displayQuestion(void) { |
|
|
printf("Actual Output:\n"); |
|
|
printf("Actual Output:\n"); |
|
|
displayQuestion(question, answers, correctIndex); |
|
|
displayQuestion(question, answers, correctIndex); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe richtig ist |
|
|
void test_processUserAnswer_correct(void) { |
|
|
void test_processUserAnswer_correct(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 0; |
|
|
int correctIndex = 0; |
|
|
int userAnswer = 1; |
|
|
int userAnswer = 1; |
|
|
|
|
|
|
|
@ -41,73 +41,73 @@ void test_processUserAnswer_correct(void) { |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe falsch ist |
|
|
void test_processUserAnswer_wrong(void) { |
|
|
void test_processUserAnswer_wrong(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 0; |
|
|
int correctIndex = 0; |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(0, score); |
|
|
TEST_ASSERT_EQUAL_INT(0, score); |
|
|
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe richtig ist |
|
|
void test_processUserAnswer_correctAnswer_index3(void) { |
|
|
void test_processUserAnswer_correctAnswer_index3(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"A", "B", "C", "D"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"A", "B", "C", "D"}; |
|
|
processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe richtig ist |
|
|
void test_processUserAnswer_correctAnswer_index0(void) { |
|
|
void test_processUserAnswer_correctAnswer_index0(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"A", "B", "C", "D"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"A", "B", "C", "D"}; |
|
|
processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe falsch ist |
|
|
void test_processUserAnswer_wrongAnswer_index3(void) { |
|
|
void test_processUserAnswer_wrongAnswer_index3(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 0; |
|
|
int correctIndex = 0; |
|
|
int userAnswer = 4; // Assuming user selects the fourth option |
|
|
int userAnswer = 4; // Assuming user selects the fourth option |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(0, score); |
|
|
TEST_ASSERT_EQUAL_INT(0, score); |
|
|
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe richtig ist |
|
|
void test_processUserAnswer_correctAnswer_index1(void) { |
|
|
void test_processUserAnswer_correctAnswer_index1(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 1; |
|
|
int correctIndex = 1; |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe richtig ist |
|
|
void test_processUserAnswer_correctAnswer_index2(void) { |
|
|
void test_processUserAnswer_correctAnswer_index2(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 2; |
|
|
int correctIndex = 2; |
|
|
int userAnswer = 3; // Assuming user selects the third option |
|
|
int userAnswer = 3; // Assuming user selects the third option |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, score); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Funktion schaut, ob User-Eingabe falsch ist |
|
|
void test_processUserAnswer_wrongAnswer_index1(void) { |
|
|
void test_processUserAnswer_wrongAnswer_index1(void) { |
|
|
int score = 0; |
|
|
int score = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
int totalCorrectAnswers = 0; |
|
|
char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
|
|
|
|
|
|
const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; |
|
|
int correctIndex = 2; |
|
|
int correctIndex = 2; |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
int userAnswer = 2; // Assuming user selects the second option |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|