|
@ -97,4 +97,68 @@ class ChessBoardTest { |
|
|
assertTrue(chessBoard.validateCleanPath(7, 3, 5, 5)); |
|
|
assertTrue(chessBoard.validateCleanPath(7, 3, 5, 5)); |
|
|
assertFalse(chessBoard.validateCleanPath(7, 3, 6, 6)); |
|
|
assertFalse(chessBoard.validateCleanPath(7, 3, 6, 6)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
0 1 2 3 4 5 6 7 |
|
|
|
|
|
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ |
|
|
|
|
|
0 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
1 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
2 │ │ │ │ │ o │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
3 │ │ │ │ |o| │ │ |o| │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
4 │ │ │ o │ │ o │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
5 │ │ │ │ |o| │ │ │ |T| │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
6 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
7 │ │ │ T │ │ B │ │ │ │ |
|
|
|
|
|
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ |
|
|
|
|
|
*/ |
|
|
|
|
|
@Test |
|
|
|
|
|
void validateMove() { |
|
|
|
|
|
ChessFigure[][] tempBoard = new ChessFigure[8][8]; |
|
|
|
|
|
|
|
|
|
|
|
tempBoard[4][2] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[4][4] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[2][4] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[3][3] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK); |
|
|
|
|
|
tempBoard[3][5] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK); |
|
|
|
|
|
tempBoard[5][3] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK); |
|
|
|
|
|
tempBoard[7][2] = new ChessFigure(ChessFigure.Type.CASTLE, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[7][4] = new ChessFigure(ChessFigure.Type.BISHOP, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[5][6] = new ChessFigure(ChessFigure.Type.CASTLE, ChessFigure.Team.BLACK); |
|
|
|
|
|
|
|
|
|
|
|
chessBoard.setChessBoard(tempBoard); |
|
|
|
|
|
|
|
|
|
|
|
//White pawn normal move |
|
|
|
|
|
assertTrue(chessBoard.validateMove(4, 2, 4, 1)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(4, 2, 4, 3)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(4, 2, 3, 1)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(4, 2, 5, 1)); |
|
|
|
|
|
//White pawn beats Black |
|
|
|
|
|
assertTrue(chessBoard.validateMove(4, 4, 3, 3)); |
|
|
|
|
|
assertTrue(chessBoard.validateMove(4, 4, 5, 3)); |
|
|
|
|
|
//Black pawn normal move |
|
|
|
|
|
assertTrue(chessBoard.validateMove(3, 5, 3, 6)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(3, 5, 3, 4)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(3, 5, 2, 6)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(3, 5, 6, 6)); |
|
|
|
|
|
//Black pawn beats White |
|
|
|
|
|
assertTrue(chessBoard.validateMove(3, 3, 2, 4)); |
|
|
|
|
|
assertTrue(chessBoard.validateMove(3, 3, 4, 4)); |
|
|
|
|
|
|
|
|
|
|
|
//CastleMoves for testing global rules |
|
|
|
|
|
assertTrue(chessBoard.validateMove(2, 7, 2, 5)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(2, 7, 2, 4)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(2, 7, 2, 2)); |
|
|
|
|
|
|
|
|
|
|
|
//Bishop Moves for testing global moves |
|
|
|
|
|
assertTrue(chessBoard.validateMove(4, 7, 5, 6)); |
|
|
|
|
|
assertTrue(chessBoard.validateMove(4, 7, 6, 5)); |
|
|
|
|
|
assertFalse(chessBoard.validateMove(4, 7, 7, 4)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |