diff options
Diffstat (limited to 'src/board.rs')
-rw-r--r-- | src/board.rs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/board.rs b/src/board.rs index 13f86ec..86c42c7 100644 --- a/src/board.rs +++ b/src/board.rs @@ -32,6 +32,7 @@ const PIECE_CHARS: [&str; 12] = [ ]; +#[allow(unused)] impl Board { #[allow(non_snake_case)] pub fn from_FEN(fen: String) -> Self { @@ -128,7 +129,7 @@ pub enum Square { #[cfg(test)] mod tests { use super::*; - use crate::bitboard; + use crate::bitboard::{pop_count, bitscan}; #[test] fn test_square_enum() { @@ -142,22 +143,22 @@ mod tests { let fen = String::from("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); let board = Board::from_FEN(fen); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Pawn as usize]), 8); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Knight as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Bishop as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Rook as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::Queen as usize]), 1); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::King as usize]), 1); - - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::PawnBlack as usize]), 8); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::KnightBlack as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::BishopBlack as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::RookBlack as usize]), 2); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::QueenBlack as usize]), 1); - assert_eq!(bitboard::pop_count(board.pieces[PieceTypes::KingBlack as usize]), 1); - - assert_eq!(bitboard::bitscan(board.pieces[PieceTypes::King as usize]), Square::E1 as u8); - assert_eq!(bitboard::bitscan(board.pieces[PieceTypes::QueenBlack as usize]), Square::D8 as u8); + assert_eq!(pop_count(board.pieces[PieceTypes::Pawn as usize]), 8); + assert_eq!(pop_count(board.pieces[PieceTypes::Knight as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::Bishop as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::Rook as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::Queen as usize]), 1); + assert_eq!(pop_count(board.pieces[PieceTypes::King as usize]), 1); + + assert_eq!(pop_count(board.pieces[PieceTypes::PawnBlack as usize]), 8); + assert_eq!(pop_count(board.pieces[PieceTypes::KnightBlack as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::BishopBlack as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::RookBlack as usize]), 2); + assert_eq!(pop_count(board.pieces[PieceTypes::QueenBlack as usize]), 1); + assert_eq!(pop_count(board.pieces[PieceTypes::KingBlack as usize]), 1); + + assert_eq!(bitscan(board.pieces[PieceTypes::King as usize]), Square::E1 as u8); + assert_eq!(bitscan(board.pieces[PieceTypes::QueenBlack as usize]), Square::D8 as u8); board.print(); } |