Browse Source

tictactoe: added test case for player 2 in playfield setter

tictactoe
Malte Schellhardt 3 years ago
committed by Lorenz Hohmann
parent
commit
8b31b76e69
  1. 4
      src/main/java/de/tims/tictactoe/GameLogic.java
  2. 8
      src/test/java/de/tims/tictactoe/GameLogicTest.java

4
src/main/java/de/tims/tictactoe/GameLogic.java

@ -25,8 +25,8 @@ public class GameLogic {
return this.board[0].length * this.board.length;
}
public void setField(int row, int column, char player) {
this.board[row][column] = player;
public void setField(int column, int row, char player) {
this.board[column][row] = player;
}
}

8
src/test/java/de/tims/tictactoe/GameLogicTest.java

@ -55,8 +55,8 @@ class GameLogicTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("testCasesForSetField")
void setFieldTest(String testName, int row, int column, char player, char[][] expectedResult) {
this.game.setField(row, column, player);
void setFieldTest(String testName, int column, int row, char player, char[][] expectedResult) {
this.game.setField(column, row, player);
char[][] realResult = this.game.getBoard();
assertArrayEquals(expectedResult, realResult);
@ -77,6 +77,10 @@ class GameLogicTest {
Arguments.of("set field [0][0] for player 1", 0, 0, 'x', new char[][]
{{'x', '-', '-'},
{'-', '-', '-'},
{'-', '-', '-'}}),
Arguments.of("set field [1][0] for player 2", 1, 0, 'o', new char[][]
{{'-', '-', '-'},
{'o', '-', '-'},
{'-', '-', '-'}})
);
}

Loading…
Cancel
Save