From f74e8420bb5067c14c62f352485677f92f137e09 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 11:02:41 +0100 Subject: [PATCH] add a test for the initialization of the game info structure --- src/main/c/Georg/tictactoe.c | 6 ++++++ src/main/c/Georg/tictactoe.h | 1 + src/test/c/Georg/test_tictactoe.c | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index 4b91348..f531dd4 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -16,3 +16,9 @@ char* getRulesMessage(){ "Mit dem Befehl \"start\" startest du das Spiel" "Mit dem Befehl \"rules\" kannst du diese Nachricht erneut aufrufen."; } + +struct ticTacToe createTicTacToe() { + struct ticTacToe newGame; + newGame.currentState = 0; + return newGame; +} \ No newline at end of file diff --git a/src/main/c/Georg/tictactoe.h b/src/main/c/Georg/tictactoe.h index d8b2a20..cc05322 100644 --- a/src/main/c/Georg/tictactoe.h +++ b/src/main/c/Georg/tictactoe.h @@ -7,5 +7,6 @@ struct ticTacToe{ char* getWelcomeMessage(); char* getRulesMessage(); +struct ticTacToe createTicTacToe(); #endif //TICTACTOE_H diff --git a/src/test/c/Georg/test_tictactoe.c b/src/test/c/Georg/test_tictactoe.c index cc7b353..cce0a6f 100644 --- a/src/test/c/Georg/test_tictactoe.c +++ b/src/test/c/Georg/test_tictactoe.c @@ -37,4 +37,16 @@ void test_rules_message(void){ // 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 ); } \ No newline at end of file