|
@ -80,4 +80,49 @@ class BoardTest { |
|
|
assertTrue(Arrays.deepEquals(expected4, Board.convertSimpleToState(test4))); |
|
|
assertTrue(Arrays.deepEquals(expected4, Board.convertSimpleToState(test4))); |
|
|
assertNull(Board.convertSimpleToState(test5)); |
|
|
assertNull(Board.convertSimpleToState(test5)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void getCurrentState() { |
|
|
|
|
|
Board.State[] testArray = Board.convertSimpleToState(new int[]{2, 2, 2, 1, 0, 1, 1, 0, 0}); |
|
|
|
|
|
Board.State[] testArray2 = Board.convertSimpleToState(new int[]{1, 0, 2, 1, 2, 0, 1, 0, 2}); |
|
|
|
|
|
Board.State[] testArray3 = Board.convertSimpleToState(new int[]{1, 0, 2, 0, 1, 2, 0, 2, 1}); |
|
|
|
|
|
Board.State[] testArray4 = Board.convertSimpleToState(new int[]{0, 1, 2, 2, 1, 0, 0, 1, 2}); |
|
|
|
|
|
Board.State[] testArray5 = Board.convertSimpleToState(new int[]{1, 0, 0, 2, 2, 2, 1, 0, 1}); |
|
|
|
|
|
Board.State[] testArray6 = Board.convertSimpleToState(new int[]{2, 0, 1, 2, 1, 0, 1, 2, 0}); |
|
|
|
|
|
Board.State[] testArray7 = Board.convertSimpleToState(new int[]{0, 0, 1, 0, 2, 1, 2, 2, 1}); |
|
|
|
|
|
Board.State[] testArray8 = Board.convertSimpleToState(new int[]{1, 0, 0, 1, 1, 0, 2, 2, 2}); |
|
|
|
|
|
|
|
|
|
|
|
Board.State[] drawArray = Board.convertSimpleToState(new int[]{2, 1, 2, 1, 2, 1, 1, 2, 1}); |
|
|
|
|
|
Board.State[] drawArray2 = Board.convertSimpleToState(new int[]{2, 2, 1, 1, 1, 2, 2, 2, 1}); |
|
|
|
|
|
Board.State[] notFinishedArray = Board.convertSimpleToState(new int[]{2, 2, 1, 2, 0, 1, 0, 0, 0}); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CROSSWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray2); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CIRCLEWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray3); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CIRCLEWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray4); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CIRCLEWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray5); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CROSSWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray6); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CIRCLEWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray7); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CIRCLEWIN); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), testArray8); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.CROSSWIN); |
|
|
|
|
|
|
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), drawArray); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.DRAW); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), drawArray2); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.DRAW); |
|
|
|
|
|
FieldSetter.setField(board, board.getClass().getDeclaredField("states"), notFinishedArray); |
|
|
|
|
|
assertEquals(board.getCurrentState(), Board.CurrentState.NOTFINISHED); |
|
|
|
|
|
|
|
|
|
|
|
} catch (NoSuchFieldException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |