cleanup board tests
This commit is contained in:
parent
b2b5fb9e2c
commit
1061292409
14
src/board.rs
14
src/board.rs
@ -95,6 +95,7 @@ lazy_static! {
|
|||||||
pub struct Board {
|
pub struct Board {
|
||||||
/// [`BitBoard`] containing all white pieces
|
/// [`BitBoard`] containing all white pieces
|
||||||
white_board: BitBoard,
|
white_board: BitBoard,
|
||||||
|
|
||||||
/// [`BitBoard`] containing all black pieces
|
/// [`BitBoard`] containing all black pieces
|
||||||
black_board: BitBoard,
|
black_board: BitBoard,
|
||||||
}
|
}
|
||||||
@ -274,6 +275,7 @@ impl Board {
|
|||||||
// if overlapping chains were to exist, `self.place_unchecked` could collide with `self.get`
|
// if overlapping chains were to exist, `self.place_unchecked` could collide with `self.get`
|
||||||
(*(self as *const Self)).propegate_from_dry(i, j, starting_color)
|
(*(self as *const Self)).propegate_from_dry(i, j, starting_color)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for &(i, j) in iterator {
|
for &(i, j) in iterator {
|
||||||
self.place_unchecked(i, j, starting_color);
|
self.place_unchecked(i, j, starting_color);
|
||||||
@ -356,9 +358,9 @@ mod test {
|
|||||||
let mut board = Board::new();
|
let mut board = Board::new();
|
||||||
board.place_unchecked(0, 0, Piece::Black);
|
board.place_unchecked(0, 0, Piece::Black);
|
||||||
board.place_unchecked(0, 1, Piece::White);
|
board.place_unchecked(0, 1, Piece::White);
|
||||||
board.place_unchecked(0, 2, Piece::Black);
|
|
||||||
|
|
||||||
board.propegate_from(0, 2);
|
assert_eq!(board.place(0, 2, Piece::Black), Ok(()));
|
||||||
|
|
||||||
assert_eq!(board.get(0, 1), Some(Piece::Black));
|
assert_eq!(board.get(0, 1), Some(Piece::Black));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,11 +369,10 @@ mod test {
|
|||||||
let mut board = Board::new();
|
let mut board = Board::new();
|
||||||
|
|
||||||
board.place_unchecked(0, 0, Piece::Black);
|
board.place_unchecked(0, 0, Piece::Black);
|
||||||
|
|
||||||
board.place_unchecked(0, 2, Piece::White);
|
board.place_unchecked(0, 2, Piece::White);
|
||||||
|
|
||||||
board.place_unchecked(0, 3, Piece::Black);
|
// should fail
|
||||||
board.propegate_from(0, 3);
|
assert_ne!(board.place(0, 3, Piece::Black), Ok(()));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
board.get(0, 1),
|
board.get(0, 1),
|
||||||
@ -390,8 +391,7 @@ mod test {
|
|||||||
board.place_unchecked(0, j, Piece::White);
|
board.place_unchecked(0, j, Piece::White);
|
||||||
}
|
}
|
||||||
|
|
||||||
board.place_unchecked(0, 7, Piece::Black);
|
assert_eq!(board.place(0, 7, Piece::Black), Ok(()));
|
||||||
board.propegate_from(0, 7);
|
|
||||||
|
|
||||||
for j in 2..=6 {
|
for j in 2..=6 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user