Browse Source

new test case for word with space

remotes/origin/Saba
Saba Fazlali 11 months ago
parent
commit
6e079cedfa
  1. BIN
      cmake-build-debug/.ninja_deps
  2. 2
      cmake-build-debug/.ninja_log
  3. 4
      cmake-build-debug/Testing/Temporary/LastTest.log
  4. 2
      src/main/c/Hangman/word_selector.c
  5. 17
      test/Hangman/test_playHangman.c

BIN
cmake-build-debug/.ninja_deps

2
cmake-build-debug/.ninja_log

@ -22,3 +22,5 @@
41 66 1707260143227530868 pmuw_projekt_notebinder a5668107eb06d295 41 66 1707260143227530868 pmuw_projekt_notebinder a5668107eb06d295
2 209 1707265395136143124 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 2 209 1707265395136143124 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6
209 296 1707265395223868349 pmuw_projekt_notebinder a5668107eb06d295 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

4
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

2
src/main/c/Hangman/word_selector.c

@ -14,7 +14,7 @@ const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = {
"year", "year",
"dealer", "dealer",
"patience", "patience",
"initiative",
"table tennis",
"pollution", "pollution",
"awareness", "awareness",
"problem", "problem",

17
test/Hangman/test_playHangman.c

@ -2,8 +2,6 @@
#include "playHangman.c" #include "playHangman.c"
#include <assert.h> #include <assert.h>
void test_displayRules() { void test_displayRules() {
// Simulate user input: 1, 2, and an invalid input // Simulate user input: 1, 2, and an invalid input
printf("Test Case 1: User enters '1' (YES)\n"); printf("Test Case 1: User enters '1' (YES)\n");
@ -43,9 +41,16 @@ void test_toLower() {
} }
void test_initializeHangman() { 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"); printf("initializeHangman test passed!\n");
} }
Loading…
Cancel
Save