MoveGen { public static boolean inCheck(Position pos) { int kingSq = pos.getKingSq(pos.whiteMove); return sqAttacked(pos, kingSq); }  final MoveList pseudoLegalMoves(Position pos); final MoveList checkEvasions(Position pos); final MoveList pseudoLegalCapturesAndChecks(Position pos); final MoveList pseudoLegalCaptures(Position pos); static boolean inCheck(Position pos); static boolean givesCheck(Position pos, Move m); static boolean canTakeKing(Position pos); static boolean sqAttacked(Position pos, int sq); static void removeIllegal(Position pos, MoveList moveList); final void returnMoveList(MoveList moveList);  }
@Test public void testInCheck() { System.out.println("inCheck"); Position pos = new Position(); pos.setPiece(Position.getSquare(4,2), Piece.WKING); pos.setPiece(Position.getSquare(4,7), Piece.BKING); assertEquals(false, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(3,3), Piece.BQUEEN); assertEquals(true, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(3,3), Piece.BROOK); assertEquals(false, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(3,3), Piece.BPAWN); assertEquals(true, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(3,3), Piece.EMPTY); pos.setPiece(Position.getSquare(5,3), Piece.WQUEEN); assertEquals(false, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(4, 6), Piece.BROOK); assertEquals(true, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(4, 4), Piece.WPAWN); assertEquals(false, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(2, 3), Piece.BKNIGHT); assertEquals(true, MoveGen.inCheck(pos)); pos.setPiece(Position.getSquare(2, 3), Piece.EMPTY); pos.setPiece(Position.getSquare(0, 4), Piece.BKNIGHT); assertEquals(false, MoveGen.inCheck(pos)); }