Browse Source

tictactoe: added test case to check end of game with empty board

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

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

@ -88,4 +88,9 @@ public class GameLogic {
return finished;
}
public boolean checkEndOfGame() {
// TODO Auto-generated method stub
return false;
}
}

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

@ -88,6 +88,14 @@ class GameLogicTest {
assertEquals(expectedResult, realResult);
}
@ParameterizedTest(name = "[{index}] {0}: should be {1}")
@MethodSource("testCasesForCheckEndOfGame")
void checkEndOfGameTest(String testName, boolean expectedResult, char[][] boardToCheck) {
boolean realResult = new GameLogic(boardToCheck).checkEndOfGame();
assertEquals(expectedResult, realResult);
}
private static Stream<Arguments> testCasesForCountPlayfields() {
return Stream.of(
Arguments.of("1x1 board with too few fields", 1, 9),
@ -212,5 +220,14 @@ class GameLogicTest {
{'o', 'x', 'x'}})
);
}
private static Stream<Arguments> testCasesForCheckEndOfGame() {
return Stream.of(
Arguments.of("check empty board", false, new char[][]
{{'-', '-', '-'},
{'-', '-', '-'},
{'-', '-', '-'}})
);
}
}
Loading…
Cancel
Save