chessfriend/position/src/macros.rs
Eryn Wells dab787170c [position] Clean up rook unit tests
Use test_position! instead of position!
Spell out the PlacedPiece constructor in the test_position! macro.
2024-01-28 10:28:01 -08:00

53 lines
1.4 KiB
Rust

// Eryn Wells <eryn@erynwells.me>
#[macro_export]
macro_rules! position {
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
$crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape),
chessfriend_core::Square::$square
)
))*
.build()
};
}
#[cfg(test)]
#[macro_export]
macro_rules! test_position {
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
{
let pos = $crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape
),
chessfriend_core::Square::$square
))
)*
.build();
println!("{pos}");
pos
}
};
(empty) => {
{
let pos = Position::empty();
println!("{pos}");
pos
}
};
(starting) => {
{
let pos = Position::starting();
println!("{pos}");
pos
}
};
}