diff --git a/board/src/macros.rs b/board/src/macros.rs index 0b88d0f..9dd3323 100644 --- a/board/src/macros.rs +++ b/board/src/macros.rs @@ -18,3 +18,17 @@ macro_rules! position { .build() }; } + +#[cfg(test)] +#[macro_export] +macro_rules! test_position { + [$($color:ident $shape:ident on $square:ident),* $(,)?] => { + { + let pos = $crate::PositionBuilder::new() + $(.place_piece(piece!($color $shape on $square)))* + .build(); + println!("{pos}"); + pos + } + }; +} diff --git a/board/src/sight.rs b/board/src/sight.rs index 9f4a10b..33bd2d8 100644 --- a/board/src/sight.rs +++ b/board/src/sight.rs @@ -174,13 +174,13 @@ mod tests { } mod pawn { - use crate::{position, sight::Sight, BitBoard, Position, Square}; + use crate::{sight::Sight, BitBoard, Square}; sight_test!(e4_pawn, piece!(White Pawn on E4), bitboard!(D5, F5)); sight_test!( e4_pawn_one_blocker, - position![ + test_position![ White Bishop on D5, White Pawn on E4, ], @@ -190,11 +190,12 @@ mod tests { #[test] fn e4_pawn_two_blocker() { - let pos = position!( + let pos = test_position!( White Bishop on D5, White Queen on F5, White Pawn on E4, ); + let pp = piece!(White Pawn on E4); let sight = pp.sight_in_position(&pos); @@ -203,11 +204,12 @@ mod tests { #[test] fn e4_pawn_capturable() { - let pos = position!( + let pos = test_position!( Black Bishop on D5, White Queen on F5, White Pawn on E4, ); + let pp = piece!(White Pawn on E4); let sight = pp.sight_in_position(&pos); @@ -216,7 +218,7 @@ mod tests { #[test] fn e5_en_passant() { - let mut pos = position!( + let mut pos = test_position!( White Pawn on E5, Black Pawn on D5, );