|
|
@ -6,70 +6,288 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setUp(void) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void setUp(void) { |
|
|
|
|
|
|
|
|
|
|
|
void tearDown(void) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_getRandomQuestionIndex(void) { |
|
|
|
|
|
|
|
int askedQuestions[10] = {0}; |
|
|
|
|
|
|
|
void tearDown(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)(16)));}} while(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_getRandomQuestionIndex(void) { |
|
|
|
void test_displayQuestion(void) { |
|
|
|
|
|
|
|
int askedQuestions[10] = {0}; |
|
|
|
char* question = "Test Question"; |
|
|
|
|
|
|
|
int totalQuestions = 10; |
|
|
|
char* answers[] = {"A", "B", "C", "D"}; |
|
|
|
|
|
|
|
int correctIndex = 0; |
|
|
|
|
|
|
|
printf("\nExpected Output:\n"); |
|
|
|
|
|
|
|
printf("Question: %s\n", question); |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
|
|
|
|
int index = getRandomQuestionIndex(askedQuestions, totalQuestions); |
|
|
|
printf("%d. %s\n", i + 1, answers[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
printf("Actual Output:\n"); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
do {if ((index >= 0 && index < totalQuestions)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0); |
|
|
|
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_displayQuestion(void) { |
|
|
|
void test_processUserAnswer_wrong(void) { |
|
|
|
|
|
|
|
char* question = "Test Question"; |
|
|
|
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; |
|
|
|
|
|
|
|
printf("\nExpected Output:\n"); |
|
|
|
int userAnswer = 4; |
|
|
|
|
|
|
|
printf("Question: %s\n", question); |
|
|
|
processUserAnswer(userAnswer, correctIndex, &score, &totalCorrectAnswers, answers); |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((score)), ( |
|
|
|
|
|
|
|
printf("%d. %s\n", i + 1, answers[i]); |
|
|
|
((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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
printf("Actual Output:\n"); |
|
|
|
|
|
|
|
displayQuestion(question, answers, correctIndex); |
|
|
|
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); |
|
|
|
|
|
|
|
} |