Add basic test for creating a gameboard representation.

This commit is contained in:
Dorian 2019-03-01 11:04:06 -05:00
parent 5e24c02cfb
commit fc9a706c90
1 changed files with 19 additions and 5 deletions

View File

@ -61,14 +61,22 @@ impl Board {
}
}
static COLUMN_COORDINATE_BORDER: &str = " ABCDEFGHIJKL";
impl fmt::Display for Board {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
// TODO: Add a A-Z and 1-12 border around the game.
let width = self.dimensions.get_size();
let height= self.dimensions.get_size();
// TODO: Implement a looping setup for the checkerboard.
// Create the top level border.
let mut column_border_chars = COLUMN_COORDINATE_BORDER.chars();
for _ in 0..width + 1 {
write!(formatter, "{}", column_border_chars.next().unwrap())?;
}
write!(formatter, "\n")?;
// for {}
//
// let square = match tile {
@ -85,8 +93,14 @@ impl fmt::Display for Board {
#[cfg(test)]
mod tests {
use crate::Board;
use crate::BoardSize;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
fn setup_international_board() {
let expected = r#" ABCDEFGHIJ
"#;
assert_eq!(Board::new(BoardSize::International).to_string(), expected);
}
}