chessfriend/board/src/tests.rs
Eryn Wells 4a54d8b877 [board] Implement KingMoveGenerator
Generate moves for kings.

This struct is trying out a different approach to iterators where the type
itself isn't one, but it has an iter() method that returns an iterator over all
the move lists.

This struct also builds all the moves up front, in new() before the new instance
is returned.
2023-12-31 16:35:34 -08:00

31 lines
799 B
Rust

// Eryn Wells <eryn@erynwells.me>
/// Test helper utilities.
use crate::Square;
/// A constructor function that returns a Square representing the square on the
/// chessboard indicated by the algebraic notation.
macro_rules! sq_constructor {
($func_name:ident) => {
pub(crate) fn $func_name() -> Square {
Square::from_algebraic_str(stringify!($func_name)).expect(stringify!($func_name))
}
};
}
impl Square {
sq_constructor!(a1);
sq_constructor!(a2);
sq_constructor!(b1);
sq_constructor!(b2);
sq_constructor!(d3);
sq_constructor!(d4);
sq_constructor!(d5);
sq_constructor!(e2);
sq_constructor!(e3);
sq_constructor!(e4);
sq_constructor!(e5);
sq_constructor!(f3);
sq_constructor!(f4);
sq_constructor!(f5);
}