Browse Source

tictactoe: added checkForWin method

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

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

@ -1,7 +1,5 @@
package de.tims.tictactoe;
import java.util.Arrays;
public class GameLogic {
private char[][] board;
@ -42,5 +40,9 @@ public class GameLogic {
}
return true;
}
public boolean checkForWin() {
return true;
}
}

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

@ -80,6 +80,14 @@ class GameLogicTest {
assertEquals(expectedResult, realResult);
}
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("testCasesForCheckForWin")
void checkForWinTest(String testName, boolean expectedResult, char[][] boardToCheck) {
boolean realResult = new GameLogic(boardToCheck).checkForWin();
assertEquals(expectedResult, realResult);
}
private static Stream<Arguments> testCasesForCountPlayfields() {
return Stream.of(
Arguments.of("1x1 board with too few fields", 1, 9),
@ -123,5 +131,14 @@ class GameLogicTest {
{'-', '-', '-'}})
);
}
private static Stream<Arguments> testCasesForCheckForWin() {
return Stream.of(
Arguments.of("check win for player 1", true, new char[][]
{{'x', '-', '-'},
{'x', '-', '-'},
{'x', '-', '-'}})
);
}
}
Loading…
Cancel
Save