use kish::{Board, Square, Team};
#[test]
fn white_pieces_on_rows_2_and_3() {
let board = Board::new_default();
let white_pieces = board.friendly_pieces();
for col in 0..8 {
let sq = Square::try_from_u8(8 + col).unwrap();
assert_ne!(
white_pieces & sq.to_mask(),
0,
"White piece should be at {sq:?}"
);
}
for col in 0..8 {
let sq = Square::try_from_u8(16 + col).unwrap();
assert_ne!(
white_pieces & sq.to_mask(),
0,
"White piece should be at {sq:?}"
);
}
}
#[test]
fn black_pieces_on_rows_6_and_7() {
let board = Board::new_default();
let black_pieces = board.hostile_pieces();
for col in 0..8 {
let sq = Square::try_from_u8(40 + col).unwrap();
assert_ne!(
black_pieces & sq.to_mask(),
0,
"Black piece should be at {sq:?}"
);
}
for col in 0..8 {
let sq = Square::try_from_u8(48 + col).unwrap();
assert_ne!(
black_pieces & sq.to_mask(),
0,
"Black piece should be at {sq:?}"
);
}
}
#[test]
fn back_rows_initially_empty() {
let board = Board::new_default();
let all_pieces = board.friendly_pieces() | board.hostile_pieces();
for col in 0..8 {
let sq = Square::try_from_u8(col).unwrap();
assert_eq!(
all_pieces & sq.to_mask(),
0,
"Row 1 should be empty at {sq:?}"
);
}
for col in 0..8 {
let sq = Square::try_from_u8(56 + col).unwrap();
assert_eq!(
all_pieces & sq.to_mask(),
0,
"Row 8 should be empty at {sq:?}"
);
}
}
#[test]
fn white_moves_first() {
let board = Board::new_default();
assert_eq!(board.turn, Team::White, "White should move first");
}
#[test]
fn no_kings_at_start() {
let board = Board::new_default();
assert_eq!(board.state.kings, 0, "No kings should exist at game start");
}
#[test]
fn middle_rows_empty_at_start() {
let board = Board::new_default();
let all_pieces = board.friendly_pieces() | board.hostile_pieces();
for col in 0..8 {
let sq = Square::try_from_u8(24 + col).unwrap();
assert_eq!(
all_pieces & sq.to_mask(),
0,
"Row 4 should be empty at {sq:?}"
);
}
for col in 0..8 {
let sq = Square::try_from_u8(32 + col).unwrap();
assert_eq!(
all_pieces & sq.to_mask(),
0,
"Row 5 should be empty at {sq:?}"
);
}
}