Browse Source

added a function that evaluates user input

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

7
src/main/c/Georg/tictactoe.c

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "tictactoe.h" #include "tictactoe.h"
@ -21,4 +22,10 @@ struct ticTacToe createTicTacToe() {
struct ticTacToe newGame; struct ticTacToe newGame;
newGame.currentState = 0; newGame.currentState = 0;
return newGame; return newGame;
}
int handleState( char* input ){
if( strcmp(input, "start game") == 0 ){
return 1;
}
} }

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

@ -8,5 +8,6 @@ struct ticTacToe{
char* getWelcomeMessage(); char* getWelcomeMessage();
char* getRulesMessage(); char* getRulesMessage();
struct ticTacToe createTicTacToe(); struct ticTacToe createTicTacToe();
int handleState( char* input );
#endif //TICTACTOE_H #endif //TICTACTOE_H

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

@ -49,4 +49,16 @@ void test_initial_state(void){
// assert // assert
TEST_ASSERT_EQUAL_INT( expectedState, newGame.currentState ); 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 );
} }
Loading…
Cancel
Save