コード例 #1
0
 @Test
 public void testPutPieceAtOneByOneRectangle() {
   board.putPieceAtRectangle(new Position(3, 3), new Position(3, 3), Piece.WATER_PIECE);
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 3)));
   assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(4, 3)));
   assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(3, 4)));
   assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(2, 3)));
   assertEquals(Piece.NULL_PIECE, board.getPieceAt(new Position(3, 2)));
 }
コード例 #2
0
 @Test
 public void testPutPieceAtTwoByTwoRectangle() {
   board.putPieceAtRectangle(new Position(4, 3), new Position(3, 5), Piece.WATER_PIECE);
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 3)));
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 4)));
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(3, 5)));
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 3)));
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 4)));
   assertEquals(Piece.WATER_PIECE, board.getPieceAt(new Position(4, 5)));
 }
コード例 #3
0
 @Test
 public void testToString() throws StrategyException {
   assertEquals(
       "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n",
       board.toString());
   board.putPieceAt(new Position(0, 0), new Piece(PieceType.BOMB, PlayerColor.RED));
   assertEquals(
       "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "bNNNNN\n",
       board.toString());
   board.putPieceAt(new Position(2, 2), new Piece(PieceType.BOMB, PlayerColor.RED));
   assertEquals(
       "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNbNNN\n" + "NNNNNN\n" + "bNNNNN\n",
       board.toString());
   board.putPieceAtRectangle(new Position(1, 4), new Position(0, 5), Piece.WATER_PIECE);
   assertEquals(
       "NNNNNN\n" + "NNNNNN\n" + "NNNNNN\n" + "NNbNNN\n" + "NNNNWW\n" + "bNNNWW\n",
       board.toString());
 }
コード例 #4
0
 @Test(expected = RuntimeException.class)
 public void testPutPieceAtRectangleVerticesOutOfOrder() {
   board.putPieceAtRectangle(new Position(0, 5), new Position(5, 0), Piece.WATER_PIECE);
 }
コード例 #5
0
 @Test(expected = ArrayIndexOutOfBoundsException.class)
 public void testPutPieceAtRectangleInvalidBottomRight() {
   board.putPieceAtRectangle(new Position(5, 0), new Position(-1, 6), Piece.WATER_PIECE);
 }
コード例 #6
0
 @Test(expected = ArrayIndexOutOfBoundsException.class)
 public void testPutPieceAtRectangleInvalidTopLeft() {
   board.putPieceAtRectangle(new Position(6, -1), new Position(0, 5), Piece.WATER_PIECE);
 }