MCPcopy Index your code
hub / github.com/coding-parrot/chess-engine / pawnIsPinned

Method pawnIsPinned

src/test/java/BoardTest.java:138–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 }
137
138 @Test
139 public void pawnIsPinned() {
140 Board board = new Board();
141 board.placeKing(4, 0, Color.WHITE);
142 board.placeRook(3, 1, Color.WHITE);
143 board.placePawn(4, 1, Color.WHITE);
144 board.placePawn(1, 4, Color.WHITE);
145 board.placePawn(1, 6, Color.WHITE);
146 board.placeKing(3, 7, Color.BLACK);
147 board.placeRook(4, 7, Color.BLACK);
148 board.placePawn(3, 5, Color.BLACK);
149 board.placePawn(6, 2, Color.BLACK);
150 board.placePawn(5, 3, Color.BLACK);
151 System.out.println(board);
152 System.out.println(board.getPiece(4, 1).getMoveList(board));
153 System.out.println(board.getLegalMoves());
154 Assert.assertTrue(board.getLegalMoves().stream().filter(move -> move.piece.sameType(PieceType.PAWN)).noneMatch(move -> move.target.row == 5));
155 board.makeMove(board.getPiece(1, 4).getMoveList(board).stream().findFirst().get());
156 System.out.println(board);
157 System.out.println(board.getPiece(6, 2).getMoveList(board));
158 board.makeMove(board.getPiece(6, 2).getMoveList(board).stream().filter(c -> Math.abs(c.piece.position.row - c.target.row) == 2).findAny().get());
159 System.out.println(board);
160 System.out.println(board.getPiece(4, 1).getMoveList(board));
161 System.out.println(board.getLegalMoves());
162 Assert.assertTrue(board.getLegalMoves().stream().filter(move -> move.piece.sameType(PieceType.PAWN)).noneMatch(move -> move.target.row == 5 && move.captureMove));
163 }
164
165 @Test
166 public void doubleCheck() {

Callers

nothing calls this directly

Calls 9

placeKingMethod · 0.95
placeRookMethod · 0.95
placePawnMethod · 0.95
getPieceMethod · 0.95
getLegalMovesMethod · 0.95
makeMoveMethod · 0.95
sameTypeMethod · 0.80
getMoveListMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected