[position] Fix broken tests build
The make_move tests were trying to access the last capture piece directly from a slice of captures pieces (implementation prior to CapturesList). Implement CapturesList::last() to return an Option<&Piece> and use it in the tests.
This commit is contained in:
parent
085697d38f
commit
19c6c6701a
2 changed files with 7 additions and 2 deletions
|
@ -8,6 +8,11 @@ use chessfriend_core::{Color, Piece};
|
|||
pub(crate) struct CapturesList([Vec<Piece>; Color::NUM]);
|
||||
|
||||
impl CapturesList {
|
||||
#[cfg(test)]
|
||||
pub fn last(&self, color: Color) -> Option<&Piece> {
|
||||
self.0[color as usize].last()
|
||||
}
|
||||
|
||||
pub fn push(&mut self, color: Color, piece: Piece) {
|
||||
self.0[color as usize].push(piece);
|
||||
}
|
||||
|
|
|
@ -407,7 +407,7 @@ mod tests {
|
|||
|
||||
assert_eq!(pos.get_piece(Square::C2), None);
|
||||
assert_eq!(pos.get_piece(Square::F5), Some(piece!(White Bishop)));
|
||||
assert_eq!(pos.captures[Color::White as usize][0], piece!(Black Rook));
|
||||
assert_eq!(pos.captures.last(Color::White), Some(&piece!(Black Rook)));
|
||||
assert_eq!(pos.board.active_color, Color::Black);
|
||||
assert_eq!(pos.board.half_move_clock, 0);
|
||||
|
||||
|
@ -444,7 +444,7 @@ mod tests {
|
|||
None,
|
||||
"capture target pawn not removed"
|
||||
);
|
||||
assert_eq!(pos.captures[Color::Black as usize][0], piece!(White Pawn));
|
||||
assert_eq!(pos.captures.last(Color::Black), Some(&piece!(White Pawn)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue