Browse Source

add a test for the initialization of the game info structure

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

6
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;
}

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

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

12
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 );
}
Loading…
Cancel
Save