|
@ -1,18 +1,21 @@ |
|
|
#include "playHangman.c" |
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
|
|
|
#include "playHangman.h" |
|
|
|
|
|
|
|
|
// Custom assert function to compare expected and actual values |
|
|
|
|
|
void assert_equal(const char *test_name, const char *expected, const char *actual) { |
|
|
|
|
|
if (strcmp(expected, actual) == 0) { |
|
|
|
|
|
printf("[PASS] %s\n", test_name); |
|
|
|
|
|
} else { |
|
|
|
|
|
printf("[FAIL] %s - Expected: \"%s\", Actual: \"%s\"\n", test_name, expected, actual); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Test function for playHangman() |
|
|
|
|
|
void test_playHangman() { |
|
|
|
|
|
char wordToGuess[] = "test"; |
|
|
|
|
|
//playHangman(wordToGuess); |
|
|
|
|
|
|
|
|
void test_displayRules() { |
|
|
|
|
|
// Simulate user input: 1, 2, and an invalid input |
|
|
|
|
|
printf("Test Case 1: User enters '1' (YES)\n"); |
|
|
|
|
|
printf("Expected Output: \"Let's get started!\"\n"); |
|
|
|
|
|
printf("Actual Output: "); |
|
|
|
|
|
displayRules(); // Call displayRules() with input 1 |
|
|
|
|
|
|
|
|
|
|
|
printf("\nTest Case 2: User enters '2' (NO)\n"); |
|
|
|
|
|
printf("Expected Output: Output of printRules()\n"); |
|
|
|
|
|
printf("Actual Output: "); |
|
|
|
|
|
displayRules(); // Call displayRules() with input 2 |
|
|
|
|
|
|
|
|
|
|
|
printf("\nTest Case 3: User enters an invalid input\n"); |
|
|
|
|
|
printf("Expected Output: \"Please enter either 1 or 2 to continue:\"\n"); |
|
|
|
|
|
printf("Actual Output: "); |
|
|
|
|
|
displayRules(); // Call displayRules() with invalid input |
|
|
} |
|
|
} |