Browse Source

refactoring: Test Datei Kommentare hinzugefügt

remotes/origin/Pascal
Pascal Schneider 11 months ago
parent
commit
f676c62551
  1. 20
      test/test_timequiz.c

20
test/test_timequiz.c

@ -8,14 +8,14 @@ void setUp(void) {
void tearDown(void) { void tearDown(void) {
} }
//Funktion schaut, ob richtger Index rausgegeben wird
void test_getRandomQuestionIndex(void) { void test_getRandomQuestionIndex(void) {
int askedQuestions[10] = {0}; int askedQuestions[10] = {0};
int totalQuestions = 10; int totalQuestions = 10;
int index = getRandomQuestionIndex(askedQuestions, totalQuestions); int index = getRandomQuestionIndex(askedQuestions, totalQuestions);
TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions); TEST_ASSERT_TRUE(index >= 0 && index < totalQuestions);
} }
//Funktion schaut, ob die Fragen richtig angezeigt werden
void test_displayQuestion(void) { void test_displayQuestion(void) {
const char* question = "Test Question"; const char* question = "Test Question";
const char* answers[] = {"A", "B", "C", "D"}; const char* answers[] = {"A", "B", "C", "D"};
@ -29,7 +29,7 @@ void test_displayQuestion(void) {
printf("Actual Output:\n"); printf("Actual Output:\n");
displayQuestion(question, answers, correctIndex); displayQuestion(question, answers, correctIndex);
} }
//Funktion schaut, ob User-Eingabe richtig ist
void test_processUserAnswer_correct(void) { void test_processUserAnswer_correct(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -41,7 +41,7 @@ void test_processUserAnswer_correct(void) {
TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe falsch ist
void test_processUserAnswer_wrong(void) { void test_processUserAnswer_wrong(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -52,7 +52,7 @@ void test_processUserAnswer_wrong(void) {
TEST_ASSERT_EQUAL_INT(0, score); TEST_ASSERT_EQUAL_INT(0, score);
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe richtig ist
void test_processUserAnswer_correctAnswer_index3(void) { void test_processUserAnswer_correctAnswer_index3(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -61,7 +61,7 @@ void test_processUserAnswer_correctAnswer_index3(void) {
TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe richtig ist
void test_processUserAnswer_correctAnswer_index0(void) { void test_processUserAnswer_correctAnswer_index0(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -70,7 +70,7 @@ void test_processUserAnswer_correctAnswer_index0(void) {
TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe falsch ist
void test_processUserAnswer_wrongAnswer_index3(void) { void test_processUserAnswer_wrongAnswer_index3(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -81,7 +81,7 @@ void test_processUserAnswer_wrongAnswer_index3(void) {
TEST_ASSERT_EQUAL_INT(0, score); TEST_ASSERT_EQUAL_INT(0, score);
TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(0, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe richtig ist
void test_processUserAnswer_correctAnswer_index1(void) { void test_processUserAnswer_correctAnswer_index1(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -92,7 +92,7 @@ void test_processUserAnswer_correctAnswer_index1(void) {
TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe richtig ist
void test_processUserAnswer_correctAnswer_index2(void) { void test_processUserAnswer_correctAnswer_index2(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;
@ -103,7 +103,7 @@ void test_processUserAnswer_correctAnswer_index2(void) {
TEST_ASSERT_EQUAL_INT(1, score); TEST_ASSERT_EQUAL_INT(1, score);
TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers); TEST_ASSERT_EQUAL_INT(1, totalCorrectAnswers);
} }
//Funktion schaut, ob User-Eingabe falsch ist
void test_processUserAnswer_wrongAnswer_index1(void) { void test_processUserAnswer_wrongAnswer_index1(void) {
int score = 0; int score = 0;
int totalCorrectAnswers = 0; int totalCorrectAnswers = 0;

Loading…
Cancel
Save