|
|
@ -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); |
|
|
|
|
|
|
|
} |