[position] Add a fen! macro
This commit is contained in:
parent
8cdb9f13b4
commit
357b811518
1 changed files with 7 additions and 4 deletions
|
@ -4,6 +4,12 @@ use crate::{r#move::Castle, Position, PositionBuilder};
|
||||||
use chessfriend_core::{piece, Color, File, Piece, PlacedPiece, Rank, Square};
|
use chessfriend_core::{piece, Color, File, Piece, PlacedPiece, Rank, Square};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
macro_rules! fen {
|
||||||
|
($fen_string:literal) => {
|
||||||
|
Position::from_fen_str($fen_string)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
pub enum ToFenError {
|
pub enum ToFenError {
|
||||||
FmtError(std::fmt::Error),
|
FmtError(std::fmt::Error),
|
||||||
|
@ -270,11 +276,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_starting_fen() {
|
fn from_starting_fen() {
|
||||||
let pos =
|
let pos = fen!("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1").unwrap();
|
||||||
Position::from_fen_str("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
|
|
||||||
.unwrap();
|
|
||||||
let expected = Position::starting();
|
let expected = Position::starting();
|
||||||
|
|
||||||
assert_eq!(pos, expected, "{pos:#?}\n{expected:#?}");
|
assert_eq!(pos, expected, "{pos:#?}\n{expected:#?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue