From de794a0f4211f5ab3b48dca7ef8959c7e0293bc9 Mon Sep 17 00:00:00 2001 From: KaffeeMaus Date: Fri, 26 Jan 2024 11:03:53 +0100 Subject: [PATCH] added a function that evaluates user input --- src/main/c/Georg/tictactoe.c | 7 +++++++ src/main/c/Georg/tictactoe.h | 1 + src/test/c/Georg/test_tictactoe.c | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/main/c/Georg/tictactoe.c b/src/main/c/Georg/tictactoe.c index f531dd4..961789b 100644 --- a/src/main/c/Georg/tictactoe.c +++ b/src/main/c/Georg/tictactoe.c @@ -1,5 +1,6 @@ #include #include +#include #include "tictactoe.h" @@ -21,4 +22,10 @@ struct ticTacToe createTicTacToe() { struct ticTacToe newGame; newGame.currentState = 0; return newGame; +} + +int handleState( char* input ){ + if( strcmp(input, "start game") == 0 ){ + return 1; + } } \ No newline at end of file diff --git a/src/main/c/Georg/tictactoe.h b/src/main/c/Georg/tictactoe.h index cc05322..2091478 100644 --- a/src/main/c/Georg/tictactoe.h +++ b/src/main/c/Georg/tictactoe.h @@ -8,5 +8,6 @@ struct ticTacToe{ char* getWelcomeMessage(); char* getRulesMessage(); struct ticTacToe createTicTacToe(); +int handleState( char* input ); #endif //TICTACTOE_H diff --git a/src/test/c/Georg/test_tictactoe.c b/src/test/c/Georg/test_tictactoe.c index cce0a6f..cd209a9 100644 --- a/src/test/c/Georg/test_tictactoe.c +++ b/src/test/c/Georg/test_tictactoe.c @@ -49,4 +49,16 @@ void test_initial_state(void){ // assert TEST_ASSERT_EQUAL_INT( expectedState, newGame.currentState ); +} + +void test_userInput(void){ + // arrange + int expectedState = 1; + char* input = "start game"; + + // act + int actualState = handleState( input ); + + // assert + TEST_ASSERT_EQUAL_INT( expectedState, actualState ); } \ No newline at end of file