macro_rules! test_move { ( $brd:expr, $m:expr, $closure:expr ) => { ... }; }
Expand description
Test a move on a ChessPosition
without actually changing its state.
§Panics
Invoking this macro will panic if the move cannot be applied to the board, i.e. if
ChessPosition::apply_legal_move
returns an error.
§Example
use crabchess::{
positions::{ChessPosition, moves::Move},
sq, pieces::Color::White, test_move
};
let mut position = ChessPosition::new();
let m = Move::read_san("Nf3", &mut position).unwrap();
let is_check = test_move!(position, m, |tp: ChessPosition| tp.is_threatened(sq!(E1), White));
assert!(!is_check);