diff --git a/build/test/cache/test_timequiz.c b/build/test/cache/test_timequiz.c index 591ce84..37a3916 100644 --- a/build/test/cache/test_timequiz.c +++ b/build/test/cache/test_timequiz.c @@ -34,9 +34,9 @@ void test_getRandomQuestionIndex(void) { void test_displayQuestion(void) { - char* question = "Test Question"; + const char* question = "Test Question"; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; int correctIndex = 0; @@ -66,7 +66,7 @@ void test_processUserAnswer_correct(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -98,7 +98,7 @@ void test_processUserAnswer_wrong(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -128,7 +128,7 @@ void test_processUserAnswer_correctAnswer_index3(void) { int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); @@ -154,7 +154,7 @@ void test_processUserAnswer_correctAnswer_index0(void) { int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); @@ -180,7 +180,7 @@ void test_processUserAnswer_wrongAnswer_index3(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -210,7 +210,7 @@ void test_processUserAnswer_correctAnswer_index1(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 1; @@ -240,7 +240,7 @@ void test_processUserAnswer_correctAnswer_index2(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; @@ -270,7 +270,7 @@ void test_processUserAnswer_wrongAnswer_index1(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; diff --git a/build/test/out/c/test_timequiz.o b/build/test/out/c/test_timequiz.o index 4ac1e70..e0c610b 100644 Binary files a/build/test/out/c/test_timequiz.o and b/build/test/out/c/test_timequiz.o differ diff --git a/build/test/out/c/timequiz.o b/build/test/out/c/timequiz.o index e4b377d..8fc0f2e 100644 Binary files a/build/test/out/c/timequiz.o and b/build/test/out/c/timequiz.o differ diff --git a/build/test/out/test_casualQuiz.out b/build/test/out/test_casualQuiz.out index 13a9f40..5da4667 100644 Binary files a/build/test/out/test_casualQuiz.out and b/build/test/out/test_casualQuiz.out differ diff --git a/build/test/out/test_quizduell.out b/build/test/out/test_quizduell.out index 58ae355..42e05d5 100644 Binary files a/build/test/out/test_quizduell.out and b/build/test/out/test_quizduell.out differ diff --git a/build/test/out/test_timequiz.out b/build/test/out/test_timequiz.out index b13c3d4..b5d13af 100644 Binary files a/build/test/out/test_timequiz.out and b/build/test/out/test_timequiz.out differ diff --git a/build/test/out/test_wwm.out b/build/test/out/test_wwm.out index debae04..ac0b5c7 100644 Binary files a/build/test/out/test_wwm.out and b/build/test/out/test_wwm.out differ diff --git a/build/test/preprocess/files/test_timequiz.c b/build/test/preprocess/files/test_timequiz.c index 591ce84..37a3916 100644 --- a/build/test/preprocess/files/test_timequiz.c +++ b/build/test/preprocess/files/test_timequiz.c @@ -34,9 +34,9 @@ void test_getRandomQuestionIndex(void) { void test_displayQuestion(void) { - char* question = "Test Question"; + const char* question = "Test Question"; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; int correctIndex = 0; @@ -66,7 +66,7 @@ void test_processUserAnswer_correct(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -98,7 +98,7 @@ void test_processUserAnswer_wrong(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -128,7 +128,7 @@ void test_processUserAnswer_correctAnswer_index3(void) { int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); @@ -154,7 +154,7 @@ void test_processUserAnswer_correctAnswer_index0(void) { int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); @@ -180,7 +180,7 @@ void test_processUserAnswer_wrongAnswer_index3(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; @@ -210,7 +210,7 @@ void test_processUserAnswer_correctAnswer_index1(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 1; @@ -240,7 +240,7 @@ void test_processUserAnswer_correctAnswer_index2(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; @@ -270,7 +270,7 @@ void test_processUserAnswer_wrongAnswer_index1(void) { int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index e81deb7..bdc3b0b 100644 --- a/build/test/results/test_casualQuiz.pass +++ b/build/test/results/test_casualQuiz.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 1.3471671999996033 +:time: 0.014675799999167793 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index b43957d..995a820 100644 --- a/build/test/results/test_quizduell.pass +++ b/build/test/results/test_quizduell.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 1.0948776999994152 +:time: 0.014967400000386988 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index f80cc93..3d0394f 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -74,4 +74,4 @@ - Correct! - Correct! - 'Wrong! The correct answer is: 3. Berlin' -:time: 0.9529290000009496 +:time: 0.8400412000009965 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index 1036db0..2aeb34a 100644 --- a/build/test/results/test_wwm.pass +++ b/build/test/results/test_wwm.pass @@ -11,4 +11,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.7791643000000477 +:time: 0.015467199998965953 diff --git a/src/timequiz.c b/src/timequiz.c index dfbdf00..64c9d9c 100644 --- a/src/timequiz.c +++ b/src/timequiz.c @@ -12,9 +12,9 @@ void timequiz(); int getRandomQuestionIndex(int askedQuestions[], int totalQuestions); -void displayQuestion(char* question, char* answers[], int correctIndex); +void displayQuestion(const char* question,const char* answers[], int correctIndex); -void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]); +void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers,const char* answers[]); int isValidAnswer(int userAnswer); @@ -115,7 +115,7 @@ void timequiz() { for (int i = 0; i < sizeof(questions) / sizeof(questions[0]); i++) { int j = rand() % 4; - char* temp = answers[i][0]; + const char* temp = answers[i][0]; answers[i][0] = answers[i][j]; answers[i][j] = temp; @@ -181,14 +181,14 @@ int getRandomQuestionIndex(int askedQuestions[], int totalQuestions) { return questionIndex; } //Frage anzeigen -void displayQuestion(char* question, char* answers[], int correctIndex) { +void displayQuestion(const char* question,const char* answers[], int correctIndex) { printf("\nQuestion: %s\n", question); for (int i = 0; i < 4; i++) { printf("%d. %s\n", i + 1, answers[i]); } } //User-Eingabe Verarbeitung -void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers, char* answers[]) { +void processUserAnswer(int userAnswer, int correctIndex, int* score, int* totalCorrectAnswers,const char* answers[]) { if (userAnswer == correctIndex + 1) { printf("Correct!\n"); (*score)++; diff --git a/test/test_timequiz.c b/test/test_timequiz.c index 71cb2b1..1483093 100644 --- a/test/test_timequiz.c +++ b/test/test_timequiz.c @@ -17,8 +17,8 @@ void test_getRandomQuestionIndex(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; printf("\nExpected Output:\n"); printf("Question: %s\n", question); @@ -33,7 +33,7 @@ void test_displayQuestion(void) { void test_processUserAnswer_correct(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; int userAnswer = 1; @@ -45,7 +45,7 @@ void test_processUserAnswer_correct(void) { void test_processUserAnswer_wrong(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; int userAnswer = 2; // Assuming user selects the second option processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); @@ -56,7 +56,7 @@ void test_processUserAnswer_wrong(void) { void test_processUserAnswer_correctAnswer_index3(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); @@ -65,7 +65,7 @@ void test_processUserAnswer_correctAnswer_index3(void) { void test_processUserAnswer_correctAnswer_index0(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"A", "B", "C", "D"}; + const char* answers[] = {"A", "B", "C", "D"}; processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); @@ -74,7 +74,7 @@ void test_processUserAnswer_correctAnswer_index0(void) { void test_processUserAnswer_wrongAnswer_index3(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 0; int userAnswer = 4; // Assuming user selects the fourth option processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); @@ -85,7 +85,7 @@ void test_processUserAnswer_wrongAnswer_index3(void) { void test_processUserAnswer_correctAnswer_index1(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 1; int userAnswer = 2; // Assuming user selects the second option processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); @@ -96,7 +96,7 @@ void test_processUserAnswer_correctAnswer_index1(void) { void test_processUserAnswer_correctAnswer_index2(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; int userAnswer = 3; // Assuming user selects the third option processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); @@ -107,7 +107,7 @@ void test_processUserAnswer_correctAnswer_index2(void) { void test_processUserAnswer_wrongAnswer_index1(void) { int score = 0; int totalCorrectAnswers = 0; - char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + const char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; int correctIndex = 2; int userAnswer = 2; // Assuming user selects the second option processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers);