From 561bfd9980276c8847ff96fb8f637514034a14fc Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Tue, 6 Feb 2024 00:09:04 +0100 Subject: [PATCH] 9 Unittest --- test/test_timequiz.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_timequiz.c b/test/test_timequiz.c index 1141e44..5d2b427 100644 --- a/test/test_timequiz.c +++ b/test/test_timequiz.c @@ -108,5 +108,19 @@ void test_processUserAnswer_correctAnswer_index1(void) { TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); } +void test_processUserAnswer_correctAnswer_index2(void) { + int score = 0; + int totalCorrectAnswers = 0; + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + int correctIndex = 2; + int userAnswer = 3; // Assuming user selects the third option + + // Call the function to process user answer + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + // Assert that the score and total correct answers are updated correctly + TEST_ASSERT_EQUAL_INT(1, score); + TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); +} #endif //TEST