Compare commits

..
2 Commits
Author SHA1 Message Date
hoangto105860 74360620be edit test_readWords_with_delimiters 2026-10-20 16:58:25 +02:00
hoangto105860 1cc06c0e2e change test_readWords_simple 2026-10-20 16:46:35 +02:00
4 changed files with 36 additions and 12 deletions

No files matched your search

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+36 -12
View File
@@ -32,27 +32,51 @@ void print_test_result(int result) {
void test_readWords_simple(void) {
FILE *f = fopen("testwords_simple.txt", "r");
char words[10][MAX_WORD_LEN];
int count = readWords(f, words, 10);
char words[14][MAX_WORD_LEN];
int count = readWords(f, words, 14);
fclose(f);
TEST_ASSERT_EQUAL_INT(3, count);
TEST_ASSERT_EQUAL_STRING("APFEL", words[0]);
TEST_ASSERT_EQUAL_STRING("BANANE", words[1]);
TEST_ASSERT_EQUAL_STRING("KIWI", words[2]);
TEST_ASSERT_EQUAL_INT(15, count);
TEST_ASSERT_EQUAL_STRING("Yeti", words[0]);
TEST_ASSERT_EQUAL_STRING("Nessie", words[1]);
TEST_ASSERT_EQUAL_STRING("Werwolf", words[2]);
TEST_ASSERT_EQUAL_STRING("Vampir", words[3]);
TEST_ASSERT_EQUAL_STRING("Monster", words[4]);
TEST_ASSERT_EQUAL_STRING("Hydra", words[5]);
TEST_ASSERT_EQUAL_STRING("Frankenstein", words[6]);
TEST_ASSERT_EQUAL_STRING("Dracula", words[7]);
TEST_ASSERT_EQUAL_STRING("KingKong", words[8]);
TEST_ASSERT_EQUAL_STRING("Gremlin", words[9]);
TEST_ASSERT_EQUAL_STRING("Kobold", words[10]);
TEST_ASSERT_EQUAL_STRING("Hexe", words[11]);
TEST_ASSERT_EQUAL_STRING("Poltergeist", words[12]);
TEST_ASSERT_EQUAL_STRING("Gespenst", words[13]);
TEST_ASSERT_EQUAL_STRING("Oger", words[14]);
}
void test_readWords_with_delimiters(void) {
FILE *f = fopen("testwords_delims.txt", "r");
char words[10][MAX_WORD_LEN];
int count = readWords(f, words, 10);
char words[14][MAX_WORD_LEN];
int count = readWords(f, words, 14);
fclose(f);
TEST_ASSERT_EQUAL_INT(3, count);
TEST_ASSERT_EQUAL_STRING("HUND", words[0]);
TEST_ASSERT_EQUAL_STRING("KATZE", words[1]);
TEST_ASSERT_EQUAL_STRING("MAUS", words[2]);
TEST_ASSERT_EQUAL_INT(15, count);
TEST_ASSERT_EQUAL_STRING("Yeti", words[0]);
TEST_ASSERT_EQUAL_STRING("Nessie", words[1]);
TEST_ASSERT_EQUAL_STRING("Werwolf", words[2]);
TEST_ASSERT_EQUAL_STRING("Vampir", words[3]);
TEST_ASSERT_EQUAL_STRING("Monster", words[4]);
TEST_ASSERT_EQUAL_STRING("Hydra", words[5]);
TEST_ASSERT_EQUAL_STRING("Frankenstein", words[6]);
TEST_ASSERT_EQUAL_STRING("Dracula", words[7]);
TEST_ASSERT_EQUAL_STRING("KingKong", words[8]);
TEST_ASSERT_EQUAL_STRING("Gremlin", words[9]);
TEST_ASSERT_EQUAL_STRING("Kobold", words[10]);
TEST_ASSERT_EQUAL_STRING("Hexe", words[11]);
TEST_ASSERT_EQUAL_STRING("Poltergeist", words[12]);
TEST_ASSERT_EQUAL_STRING("Gespenst", words[13]);
TEST_ASSERT_EQUAL_STRING("Oger", words[14]);
}
void test_readWords_empty_file(void) {