Browse Source

add gameCommandHandler

remotes/origin/georg
KaffeeMaus 11 months ago
parent
commit
ce7a6ba66c
  1. 8
      src/main/c/Georg/tictactoe.c
  2. 1
      src/main/c/Georg/tictactoe.h
  3. 12
      src/test/c/Georg/test_tictactoe.c

8
src/main/c/Georg/tictactoe.c

@ -96,6 +96,14 @@ void initializeBoard( bool board[BORAD_SIZE][BORAD_SIZE] ){
} }
} }
int handleGameInput( char* input ){
if( strstr(input, "set") != NULL ){
return 1;
}else{
return false;
}
}
int startMenu( int code ){ int startMenu( int code ){
if( code == -1 ){ // command test if( code == -1 ){ // command test
return 1; return 1;

1
src/main/c/Georg/tictactoe.h

@ -31,6 +31,7 @@ char* getRulesMessageTicTacToe(void);
struct ticTacToe createTicTacToe(); struct ticTacToe createTicTacToe();
int handleCommand( char* input ); int handleCommand( char* input );
void initializeBoard( bool board[3][3] ); void initializeBoard( bool board[3][3] );
int handleGameInput( char* input );
/* commands */ /* commands */
commandFunction getCommandById(int id); commandFunction getCommandById(int id);

12
src/test/c/Georg/test_tictactoe.c

@ -127,3 +127,15 @@ void test_initializeBoard(void){
} }
} }
} }
void test_handleGameInput(void){
// arrange
char* teststring = "set 3,4";
int expectedState = 1;
// act
int actualState = handleGameInput( teststring );
// assert
TEST_ASSERT_EQUAL_INT( expectedState, actualState );
}
Loading…
Cancel
Save