Fix the pawn unit tests

This commit is contained in:
Eryn Wells 2024-02-25 10:51:27 -08:00
parent 63c03fb879
commit 2a6b098cb8
4 changed files with 112 additions and 45 deletions

View file

@ -1,5 +1,6 @@
// Eryn Wells <eryn@erynwells.me>
use crate::Color;
use std::fmt;
use std::str::FromStr;
@ -168,6 +169,16 @@ impl Rank {
/// assert_eq!(Rank::PAWN_STARTING_RANKS[Color::Black as usize], Rank::SEVEN);
/// ```
pub const PAWN_STARTING_RANKS: [Rank; 2] = [Rank::TWO, Rank::SEVEN];
pub const PAWN_DOUBLE_PUSH_TARGET_RANKS: [Rank; 2] = [Rank::FOUR, Rank::FIVE];
pub fn is_pawn_starting_rank(&self, color: Color) -> bool {
self == &Self::PAWN_STARTING_RANKS[color as usize]
}
pub fn is_pawn_double_push_target_rank(&self, color: Color) -> bool {
self == &Self::PAWN_DOUBLE_PUSH_TARGET_RANKS[color as usize]
}
}
#[rustfmt::skip]