kfkama
3 years ago
3 changed files with 65 additions and 2 deletions
-
25src/main/java/TicTacToe/TicTacToeGame.java
-
2src/main/java/TicTacToe/cell.java
-
40src/test/java/TicTacToe/TicTacToeGameTest.java
@ -1,8 +1,48 @@ |
|||
package TicTacToe; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
import java.util.stream.Stream; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
import org.junit.jupiter.params.ParameterizedTest; |
|||
import org.junit.jupiter.params.provider.Arguments; |
|||
import org.junit.jupiter.params.provider.MethodSource; |
|||
|
|||
import Arcade64.Arcade64.Code; |
|||
|
|||
class TicTacToeGameTest { |
|||
|
|||
@ParameterizedTest |
|||
@MethodSource("testFieldsWinning") |
|||
void testGameEndWin(int[] _field, int _winner) { |
|||
TicTacToeGame ttt = new TicTacToeGame(); |
|||
|
|||
for(int i = 0; i < ttt.field.length; i++) { |
|||
ttt.field[i].value = _field[i]; |
|||
} |
|||
ttt.player = _winner; |
|||
int realWinner = ttt.checkPlayfield(); |
|||
|
|||
assertEquals(_winner, realWinner); |
|||
} |
|||
|
|||
private static Stream<Arguments> testFieldsWinning(){ |
|||
return Stream.of( |
|||
Arguments.of(new int[]{ 1,2,1, |
|||
2,2,2, |
|||
1,2,1}, 2), |
|||
Arguments.of(new int[]{ 2,1,2, |
|||
2,2,1, |
|||
1,1,1}, 1), |
|||
Arguments.of(new int[]{ 1,1,2, |
|||
1,2,2, |
|||
1,2,1}, 1), |
|||
Arguments.of(new int[]{ 2,1,1, |
|||
1,2,1, |
|||
1,1,2}, 2) |
|||
); |
|||
|
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue