|
@ -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"); |
|
|
} |
|
|
} |