|
|
@ -4,10 +4,12 @@ import Game.Tictactoe; |
|
|
|
import org.junit.jupiter.api.AfterEach; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.mockito.internal.util.reflection.FieldSetter; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
|
|
|
class BoardTest { |
|
|
|
|
|
|
@ -59,4 +61,23 @@ class BoardTest { |
|
|
|
board.getStates()[0] = Board.State.CROSS; |
|
|
|
assertEquals(board, secondBoard); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
void convertSimpleToState() { |
|
|
|
int[] test = {1, 1, 1, 2, 0, 2, 2, 0, 0}; |
|
|
|
Board.State[] expected = {Board.State.CIRCLE, Board.State.CIRCLE, Board.State.CIRCLE, Board.State.CROSS, Board.State.EMPTY, Board.State.CROSS, Board.State.CROSS, Board.State.EMPTY, Board.State.EMPTY}; |
|
|
|
int[] test2 = {1, 0, 0, 1, 0, 0, 1, 0, 0}; |
|
|
|
Board.State[] expected2 = {Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY}; |
|
|
|
int[] test3 = {69, 0, 0, 0, 1, 0, 0, 0, 1}; |
|
|
|
Board.State[] expected3 = {Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE}; |
|
|
|
int[] test4 = {3, 0, 0, 0, 1, 0, 0, 0, 1}; |
|
|
|
Board.State[] expected4 = {Board.State.EMPTY, Board.State.EMPTY, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE, Board.State.EMPTY, Board.State.EMPTY, Board.State.EMPTY, Board.State.CIRCLE}; |
|
|
|
int[] test5 = {3, 0, 0, 0, 1, 0, 0, 0}; |
|
|
|
assertTrue(Arrays.deepEquals(expected, Board.convertSimpleToState(test))); |
|
|
|
assertTrue(Arrays.deepEquals(expected2, Board.convertSimpleToState(test2))); |
|
|
|
assertFalse(Arrays.deepEquals(expected3, Board.convertSimpleToState(test3))); |
|
|
|
assertTrue(Arrays.deepEquals(expected4, Board.convertSimpleToState(test4))); |
|
|
|
assertNull(Board.convertSimpleToState(test5)); |
|
|
|
} |
|
|
|
} |