|
@ -24,6 +24,21 @@ class TicTacToeGameTest { |
|
|
assertEquals(_winner, realWinner); |
|
|
assertEquals(_winner, realWinner); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("testFieldsDraw") |
|
|
|
|
|
void testGameEndDraw(int[] _field) { |
|
|
|
|
|
TicTacToeGame ttt = new TicTacToeGame(); |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < ttt.field.length; i++) { |
|
|
|
|
|
ttt.field[i].playerID = _field[i]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int noWinner = ttt.checkPlayfield(); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(0, noWinner); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Stream<Arguments> testFieldsWinning(){ |
|
|
private static Stream<Arguments> testFieldsWinning(){ |
|
|
return Stream.of( |
|
|
return Stream.of( |
|
|
Arguments.of(new int[]{ 1,2,1, |
|
|
Arguments.of(new int[]{ 1,2,1, |
|
@ -39,6 +54,23 @@ class TicTacToeGameTest { |
|
|
1,2,1, |
|
|
1,2,1, |
|
|
1,1,2}, 2) |
|
|
1,1,2}, 2) |
|
|
); |
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Stream<Arguments> testFieldsDraw(){ |
|
|
|
|
|
return Stream.of( |
|
|
|
|
|
Arguments.of(new int[]{ 2,1,1, |
|
|
|
|
|
2,2,2, |
|
|
|
|
|
1,2,1}), |
|
|
|
|
|
Arguments.of(new int[]{ 2,1,2, |
|
|
|
|
|
2,2,1, |
|
|
|
|
|
1,2,1}), |
|
|
|
|
|
Arguments.of(new int[]{ 2,1,2, |
|
|
|
|
|
1,2,2, |
|
|
|
|
|
1,2,1}), |
|
|
|
|
|
Arguments.of(new int[]{ 2,1,1, |
|
|
|
|
|
1,2,2, |
|
|
|
|
|
2,1,1}) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|