Fix a couple of the obscure en passant cases from PEJ
This commit is contained in:
parent
673d57c02e
commit
8f07e08500
3 changed files with 77 additions and 20 deletions
|
|
@ -145,12 +145,12 @@ fn en_passant_check_capture() -> TestResult {
|
|||
|
||||
assert!(pos.is_king_in_check());
|
||||
|
||||
let generated_moves = pos.moves().iter().collect::<HashSet<_>>();
|
||||
let generated_moves: HashSet<_> = pos.moves().iter().collect();
|
||||
|
||||
assert!(
|
||||
generated_moves.contains(
|
||||
&MoveBuilder::push(&piece!(Black Pawn on E4))
|
||||
.capturing_en_passant_on(Square::D4)
|
||||
.capturing_en_passant_on(Square::D3)
|
||||
.build()?
|
||||
),
|
||||
"Valid moves: {:?}",
|
||||
|
|
@ -171,12 +171,12 @@ fn en_passant_check_block() -> TestResult {
|
|||
|
||||
assert!(pos.is_king_in_check());
|
||||
|
||||
let generated_moves = pos.moves().iter().collect::<HashSet<_>>();
|
||||
let generated_moves: HashSet<_> = pos.moves().iter().collect();
|
||||
|
||||
assert!(
|
||||
generated_moves.contains(
|
||||
&MoveBuilder::push(&piece!(Black Pawn on E4))
|
||||
.capturing_en_passant_on(Square::D4)
|
||||
.capturing_en_passant_on(Square::D3)
|
||||
.build()?
|
||||
),
|
||||
"Valid moves: {:?}",
|
||||
|
|
@ -187,7 +187,7 @@ fn en_passant_check_block() -> TestResult {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn pinned_pieces_rook_cannot_move_out_of_pin() -> Result<(), String> {
|
||||
fn pinned_pieces_rook_cannot_move_out_of_pin() -> TestResult {
|
||||
let pos = test_position!(Black, [
|
||||
Black King on E8,
|
||||
Black Rook on E6,
|
||||
|
|
@ -200,15 +200,15 @@ fn pinned_pieces_rook_cannot_move_out_of_pin() -> Result<(), String> {
|
|||
let generated_moves = pos.moves();
|
||||
let rook_moves = generated_moves
|
||||
.moves_for_piece(&piece!(Black Rook on E6))
|
||||
.ok_or("No valid rook moves")?;
|
||||
.ok_or(TestError::NoLegalMoves)?;
|
||||
|
||||
assert!(!rook_moves.can_move_to_square(Square::D6));
|
||||
assert!(!rook_moves.can_move_to_square(Square::F6));
|
||||
|
||||
assert!(rook_moves.can_move_to_square(Square::E7));
|
||||
assert!(rook_moves.can_move_to_square(Square::E5));
|
||||
assert!(rook_moves.can_move_to_square(Square::E4));
|
||||
assert!(rook_moves.can_move_to_square(Square::E3));
|
||||
assert!(rook_moves.can_move_to_square(Square::E4));
|
||||
assert!(rook_moves.can_move_to_square(Square::E5));
|
||||
assert!(rook_moves.can_move_to_square(Square::E7));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -222,10 +222,10 @@ fn en_passant_discovered_check() -> TestResult {
|
|||
White Queen on H4,
|
||||
], D3);
|
||||
|
||||
let generated_moves = pos.moves().iter().collect::<HashSet<_>>();
|
||||
let generated_moves: HashSet<_> = pos.moves().iter().collect();
|
||||
|
||||
let unexpected_move = MoveBuilder::push(&piece!(Black Pawn on E4))
|
||||
.capturing_en_passant_on(Square::D4)
|
||||
.capturing_en_passant_on(Square::D3)
|
||||
.build()?;
|
||||
|
||||
assert!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue