[board] Some test helpers that produce Squares from algebraic notiation and assert their validity
This commit is contained in:
parent
5e47d37aa3
commit
5039d657ae
2 changed files with 25 additions and 0 deletions
|
@ -1,9 +1,14 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
mod bitboard;
|
||||
mod moves;
|
||||
pub mod piece;
|
||||
mod position;
|
||||
mod square;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use moves::Move;
|
||||
pub use position::Position;
|
||||
pub use square::Square;
|
||||
|
|
20
board/src/tests.rs
Normal file
20
board/src/tests.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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!(e2);
|
||||
sq_constructor!(e3);
|
||||
sq_constructor!(e4);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue