From 6e079cedfa5cdcfbd01fa99bcee9cd21faf2a0c4 Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Wed, 7 Feb 2024 01:52:18 +0100 Subject: [PATCH] new test case for word with space --- cmake-build-debug/.ninja_deps | Bin 38716 -> 39088 bytes cmake-build-debug/.ninja_log | 2 ++ .../Testing/Temporary/LastTest.log | 4 ++-- src/main/c/Hangman/word_selector.c | 2 +- test/Hangman/test_playHangman.c | 17 +++++++++++------ 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index ad32c4ec4524529a6b8eeae7125ce3d329ed0701..9978f2d783bcd1807b0d667abcbd5b1b9be116d4 100644 GIT binary patch delta 40 vcmdn9j%mY2rVTdJMGF`i8Uh#?7^Xho{nR^eqj(^Y9kh9&tU2T42Pzr>H75>H delta 9 Qcmdn6k!jC5rVTdJ0T#prQvd(} diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index 1ced4ca..5e1153a 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -22,3 +22,5 @@ 41 66 1707260143227530868 pmuw_projekt_notebinder a5668107eb06d295 2 209 1707265395136143124 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 209 296 1707265395223868349 pmuw_projekt_notebinder a5668107eb06d295 +0 192 1707267006006028181 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421 +192 278 1707267006091837249 pmuw_projekt_notebinder a5668107eb06d295 diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index d4630a9..cf33378 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Feb 07 01:43 CET +Start testing: Feb 07 01:50 CET ---------------------------------------------------------- -End testing: Feb 07 01:43 CET +End testing: Feb 07 01:50 CET diff --git a/src/main/c/Hangman/word_selector.c b/src/main/c/Hangman/word_selector.c index 157fb93..5b2b914 100644 --- a/src/main/c/Hangman/word_selector.c +++ b/src/main/c/Hangman/word_selector.c @@ -14,7 +14,7 @@ const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = { "year", "dealer", "patience", - "initiative", + "table tennis", "pollution", "awareness", "problem", diff --git a/test/Hangman/test_playHangman.c b/test/Hangman/test_playHangman.c index 3f7ba5a..94e9743 100644 --- a/test/Hangman/test_playHangman.c +++ b/test/Hangman/test_playHangman.c @@ -2,8 +2,6 @@ #include "playHangman.c" #include - - void test_displayRules() { // Simulate user input: 1, 2, and an invalid input printf("Test Case 1: User enters '1' (YES)\n"); @@ -43,9 +41,16 @@ void test_toLower() { } void test_initializeHangman() { - char wordToGuess[] = "hangman"; - char currentGuess[8]; - initializeHangman(wordToGuess, currentGuess); - assert(strcmp(currentGuess, "_______") == 0); + // Test case 1: Word with alphabets only + char wordToGuess1[] = "hangman"; + char currentGuess1[8]; // Make sure this size is enough to accommodate the wordToGuess and the null terminator + initializeHangman(wordToGuess1, currentGuess1); + assert(strcmp(currentGuess1, "_______") == 0); + + // Test case 2: Word with spaces (e.g: table tennis) + char wordToGuess2[] = "hello world"; + char currentGuess2[12]; // Make sure this size is enough to accommodate the wordToGuess and the null terminator + initializeHangman(wordToGuess2, currentGuess2); + assert(strcmp(currentGuess2, "_____ _____") == 0); printf("initializeHangman test passed!\n"); } \ No newline at end of file