[position] Clean up rook unit tests
Use test_position! instead of position! Spell out the PlacedPiece constructor in the test_position! macro.
This commit is contained in:
parent
ea74b214da
commit
dab787170c
2 changed files with 14 additions and 7 deletions
|
@ -22,7 +22,15 @@ macro_rules! test_position {
|
|||
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
|
||||
{
|
||||
let pos = $crate::PositionBuilder::new()
|
||||
$(.place_piece(piece!($color $shape on $square)))*
|
||||
$(.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
|
||||
|
|
|
@ -60,14 +60,13 @@ impl MoveGeneratorInternal for ClassicalMoveGenerator {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{position, position::DiagramFormatter};
|
||||
use crate::{position::DiagramFormatter, test_position};
|
||||
use chessfriend_bitboard::{bitboard, BitBoard};
|
||||
use chessfriend_core::Color;
|
||||
|
||||
#[test]
|
||||
fn classical_single_rook_bitboard() {
|
||||
let pos = position![White Rook on A2];
|
||||
println!("{}", DiagramFormatter::new(&pos));
|
||||
let pos = test_position![White Rook on A2];
|
||||
|
||||
let generator = ClassicalMoveGenerator::new(&pos, Color::White);
|
||||
|
||||
|
@ -80,7 +79,7 @@ mod tests {
|
|||
/// Test that a rook can move up to, but not onto, a friendly piece.
|
||||
#[test]
|
||||
fn classical_single_rook_with_same_color_blocker_bitboard() {
|
||||
let mut pos = position![
|
||||
let pos = test_position![
|
||||
White Rook on A1,
|
||||
White Knight on E1,
|
||||
];
|
||||
|
@ -100,7 +99,7 @@ mod tests {
|
|||
/// Test that a rook can move up to, and then capture, an enemy piece.
|
||||
#[test]
|
||||
fn classical_single_rook_with_opposing_color_blocker_bitboard() {
|
||||
let pos = position![
|
||||
let pos = test_position![
|
||||
White Rook on A1,
|
||||
Black Knight on E1,
|
||||
];
|
||||
|
@ -115,7 +114,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn classical_single_rook_in_center() {
|
||||
let pos = position![White Rook on D4];
|
||||
let pos = test_position![White Rook on D4];
|
||||
|
||||
let generator = ClassicalMoveGenerator::new(&pos, Color::White);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue