Board: add test for formatting
This commit is contained in:
parent
92b982cf35
commit
8b50273b43
@ -96,9 +96,9 @@ impl fmt::Display for Board {
|
|||||||
const SPACE_PADDING: &str = const_str::repeat!(" ", PADDING);
|
const SPACE_PADDING: &str = const_str::repeat!(" ", PADDING);
|
||||||
|
|
||||||
// Print numbers at top so the board can be read more easier
|
// Print numbers at top so the board can be read more easier
|
||||||
write!(f, "{} ", SPACE_PADDING)?;
|
write!(f, "{}", SPACE_PADDING)?;
|
||||||
for j in (0..Self::SIZE).rev() {
|
for j in (0..Self::SIZE).rev() {
|
||||||
write!(f, "{:0PADDING$} ", j)?;
|
write!(f, " {:0PADDING$}", j)?;
|
||||||
}
|
}
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
|
|
||||||
@ -530,4 +530,31 @@ mod test {
|
|||||||
|
|
||||||
assert_eq!(board.get((6, 0).into()), Some(Piece::Black), "\n{}", board);
|
assert_eq!(board.get((6, 0).into()), Some(Piece::Black), "\n{}", board);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn format_test() {
|
||||||
|
assert_eq!(
|
||||||
|
Board::new().starting_pos().to_string().as_str(),
|
||||||
|
" 7 6 5 4 3 2 1 0
|
||||||
|
-----------------
|
||||||
|
7| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
6| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
5| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
4| | | |■|□| | | |
|
||||||
|
-----------------
|
||||||
|
3| | | |□|■| | | |
|
||||||
|
-----------------
|
||||||
|
2| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
1| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
0| | | | | | | | |
|
||||||
|
-----------------
|
||||||
|
White Score: 2
|
||||||
|
Black Score: 2\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user