From 3bd89c3243eae99d7410a83f759e3084cb5e41ac Mon Sep 17 00:00:00 2001 From: Pascal Schneider Date: Tue, 6 Feb 2024 00:07:03 +0100 Subject: [PATCH] 7. Unittest --- test/test_timequiz.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/test_timequiz.c b/test/test_timequiz.c index a24b0df..b7f9378 100644 --- a/test/test_timequiz.c +++ b/test/test_timequiz.c @@ -86,4 +86,15 @@ void test_processUserAnswer_correctAnswer_index0(void) { TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); } +void test_processUserAnswer_wrongAnswer_index3(void) { + int score = 0; + int totalCorrectAnswers = 0; + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + int correctIndex = 0; + int userAnswer = 4; // Assuming user selects the fourth option + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + TEST_ASSERT_EQUAL_INT(0, score); + TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); +} + #endif //TEST