|
@ -0,0 +1,76 @@ |
|
|
|
|
|
#include "tictactoe.h" |
|
|
|
|
|
#include "unity.h" |
|
|
|
|
|
|
|
|
|
|
|
void setup(void){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void tearDown(void){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_compileTest_shutBeAllwaysTrue(void){ |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT(1,1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_welcome_message(void){ |
|
|
|
|
|
// arrange |
|
|
|
|
|
char* expectedMessage = "Hallo und willkommen zu unserem TicTacToe Spiel. Anbei die Anleitung:\n"; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
char* message = getWelcomeMessage(); |
|
|
|
|
|
|
|
|
|
|
|
// aassert |
|
|
|
|
|
TEST_ASSERT_EQUAL_STRING(expectedMessage, message); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_rules_message(void){ |
|
|
|
|
|
// arrange |
|
|
|
|
|
char* expectedMessage = "Das spiel wird über die Komandozeile gespielt.\n" |
|
|
|
|
|
"Jeder Spielzug ist eine Eingabe in die Konsole. Die enstsprechenden Befehle stehen jeweils unterhalb des Spielfelds.\n" |
|
|
|
|
|
"Um ein Zug zu tätigen musst du \"set x,y\" in die Konsole Eingeben. Die Koordinaten stehen dabei für Zeile und Spalte.\n" |
|
|
|
|
|
"Mit dem Befehl \"start\" startest du das Spiel" |
|
|
|
|
|
"Mit dem Befehl \"rules\" kannst du diese Nachricht erneut aufrufen."; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
char* message = getRulesMessage(); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
TEST_ASSERT_EQUAL_STRING(expectedMessage, message); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_initial_state(void){ |
|
|
|
|
|
// arrange |
|
|
|
|
|
struct ticTacToe newGame; |
|
|
|
|
|
int expectedState = 0; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
newGame = createTicTacToe(); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT( expectedState, newGame.currentState ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_command_startGame(void){ |
|
|
|
|
|
// arrange |
|
|
|
|
|
int expectedState = 1; |
|
|
|
|
|
char* input = "start game"; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
int actualState = handleCommand( input ); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT( expectedState, actualState ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_command_startMenu(void){ |
|
|
|
|
|
// arrange |
|
|
|
|
|
int expectedState = 0; |
|
|
|
|
|
char* input = "start menu"; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
int actualState = handleCommand( input ); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
TEST_ASSERT_EQUAL_INT( expectedState, actualState ); |
|
|
|
|
|
} |