diff --git a/build/test/cache/test_timequiz.c b/build/test/cache/test_timequiz.c index 8809219..591ce84 100644 --- a/build/test/cache/test_timequiz.c +++ b/build/test/cache/test_timequiz.c @@ -6,22 +6,14 @@ - - void setUp(void) { - - } - - void tearDown(void) { - - } @@ -32,17 +24,9 @@ void test_getRandomQuestionIndex(void) { int totalQuestions = 10; - - - - int index = getRandomQuestionIndex(askedQuestions, totalQuestions); - - - - - do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0); + do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(16)));}} while(0); } @@ -73,3 +57,237 @@ void test_displayQuestion(void) { displayQuestion(question, answers, correctIndex); } + + + +void test_processUserAnswer_correct(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 1; + + + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(42), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrong(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(52), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(53), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index3(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"A", "B", "C", "D"}; + + processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(61), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(62), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index0(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"A", "B", "C", "D"}; + + processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(70), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(71), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrongAnswer_index3(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 4; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(81), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index1(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 1; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(92), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(93), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index2(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 2; + + int userAnswer = 3; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(103), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrongAnswer_index1(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 2; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(114), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(115), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/out/c/test_timequiz.o b/build/test/out/c/test_timequiz.o index f8234ce..4ac1e70 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/test_timequiz_runner.o b/build/test/out/c/test_timequiz_runner.o index 1699294..c07f490 100644 Binary files a/build/test/out/c/test_timequiz_runner.o and b/build/test/out/c/test_timequiz_runner.o differ diff --git a/build/test/out/c/timequiz.o b/build/test/out/c/timequiz.o index c71585b..a5a2192 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_timequiz.out b/build/test/out/test_timequiz.out index fa6fec4..0e45e3b 100755 Binary files a/build/test/out/test_timequiz.out and b/build/test/out/test_timequiz.out differ diff --git a/build/test/preprocess/files/test_timequiz.c b/build/test/preprocess/files/test_timequiz.c index 8809219..591ce84 100644 --- a/build/test/preprocess/files/test_timequiz.c +++ b/build/test/preprocess/files/test_timequiz.c @@ -6,22 +6,14 @@ - - void setUp(void) { - - } - - void tearDown(void) { - - } @@ -32,17 +24,9 @@ void test_getRandomQuestionIndex(void) { int totalQuestions = 10; - - - - int index = getRandomQuestionIndex(askedQuestions, totalQuestions); - - - - - do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0); + do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(16)));}} while(0); } @@ -73,3 +57,237 @@ void test_displayQuestion(void) { displayQuestion(question, answers, correctIndex); } + + + +void test_processUserAnswer_correct(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 1; + + + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(42), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrong(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(52), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(53), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index3(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"A", "B", "C", "D"}; + + processUserAnswer(4, 3, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(61), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(62), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index0(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"A", "B", "C", "D"}; + + processUserAnswer(1, 0, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(70), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(71), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrongAnswer_index3(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 0; + + int userAnswer = 4; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(81), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index1(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 1; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(92), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(93), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_correctAnswer_index2(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 2; + + int userAnswer = 3; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(103), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_processUserAnswer_wrongAnswer_index1(void) { + + int score = 0; + + int totalCorrectAnswers = 0; + + char* answers[] = {"Paris", "London", "Berlin", "Madrid"}; + + int correctIndex = 2; + + int userAnswer = 2; + + processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( + + ((void *)0) + + ), (UNITY_UINT)(114), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((totalCorrectAnswers)), ( + + ((void *)0) + + ), (UNITY_UINT)(115), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/results/test_casualQuiz.pass b/build/test/results/test_casualQuiz.pass index d81470f..0054265 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: 0.01952290000008361 +:time: 0.015700600000855047 diff --git a/build/test/results/test_quizduell.pass b/build/test/results/test_quizduell.pass index 43b9769..c4843d1 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: 0.016257900000709924 +:time: 0.015422999998918385 diff --git a/build/test/results/test_timequiz.pass b/build/test/results/test_timequiz.pass index 90c0fdb..bbb710d 100644 --- a/build/test/results/test_timequiz.pass +++ b/build/test/results/test_timequiz.pass @@ -4,18 +4,50 @@ :file: test_timequiz.c :successes: - :test: test_getRandomQuestionIndex - :line: 16 + :line: 12 :message: '' :unity_test_time: 0 - :test: test_displayQuestion - :line: 27 + :line: 19 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_correct + :line: 33 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_wrong + :line: 45 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_correctAnswer_index3 + :line: 56 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_correctAnswer_index0 + :line: 65 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_wrongAnswer_index3 + :line: 74 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_correctAnswer_index1 + :line: 85 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_correctAnswer_index2 + :line: 96 + :message: '' + :unity_test_time: 0 +- :test: test_processUserAnswer_wrongAnswer_index1 + :line: 107 :message: '' :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 2 - :passed: 2 + :total: 10 + :passed: 10 :failed: 0 :ignored: 0 :stdout: @@ -34,4 +66,12 @@ - 2. B - 3. C - 4. D -:time: 0.03188090000003285 +- Correct! +- 'Wrong! The correct answer is: 1. Paris' +- Correct! +- Correct! +- 'Wrong! The correct answer is: 1. Paris' +- Correct! +- Correct! +- 'Wrong! The correct answer is: 3. Berlin' +:time: 0.033077699999921606 diff --git a/build/test/results/test_wwm.pass b/build/test/results/test_wwm.pass index efd65ac..44efd99 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.016452499999104475 +:time: 0.015287000000171247 diff --git a/build/test/runners/test_timequiz_runner.c b/build/test/runners/test_timequiz_runner.c index 0779822..4b1fdbd 100644 --- a/build/test/runners/test_timequiz_runner.c +++ b/build/test/runners/test_timequiz_runner.c @@ -12,6 +12,14 @@ extern void setUp(void); extern void tearDown(void); extern void test_getRandomQuestionIndex(void); extern void test_displayQuestion(void); +extern void test_processUserAnswer_correct(void); +extern void test_processUserAnswer_wrong(void); +extern void test_processUserAnswer_correctAnswer_index3(void); +extern void test_processUserAnswer_correctAnswer_index0(void); +extern void test_processUserAnswer_wrongAnswer_index3(void); +extern void test_processUserAnswer_correctAnswer_index1(void); +extern void test_processUserAnswer_correctAnswer_index2(void); +extern void test_processUserAnswer_wrongAnswer_index1(void); /*=======Mock Management=====*/ @@ -76,8 +84,16 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l int main(void) { UnityBegin("test_timequiz.c"); - run_test(test_getRandomQuestionIndex, "test_getRandomQuestionIndex", 16); - run_test(test_displayQuestion, "test_displayQuestion", 27); + run_test(test_getRandomQuestionIndex, "test_getRandomQuestionIndex", 12); + run_test(test_displayQuestion, "test_displayQuestion", 19); + run_test(test_processUserAnswer_correct, "test_processUserAnswer_correct", 33); + run_test(test_processUserAnswer_wrong, "test_processUserAnswer_wrong", 45); + run_test(test_processUserAnswer_correctAnswer_index3, "test_processUserAnswer_correctAnswer_index3", 56); + run_test(test_processUserAnswer_correctAnswer_index0, "test_processUserAnswer_correctAnswer_index0", 65); + run_test(test_processUserAnswer_wrongAnswer_index3, "test_processUserAnswer_wrongAnswer_index3", 74); + run_test(test_processUserAnswer_correctAnswer_index1, "test_processUserAnswer_correctAnswer_index1", 85); + run_test(test_processUserAnswer_correctAnswer_index2, "test_processUserAnswer_correctAnswer_index2", 96); + run_test(test_processUserAnswer_wrongAnswer_index1, "test_processUserAnswer_wrongAnswer_index1", 107); return UnityEnd(); }