Add basic test for creating a gameboard representation.
This commit is contained in:
parent
5e24c02cfb
commit
fc9a706c90
|
@ -61,14 +61,22 @@ impl Board {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static COLUMN_COORDINATE_BORDER: &str = " ABCDEFGHIJKL";
|
||||||
|
|
||||||
impl fmt::Display for Board {
|
impl fmt::Display for Board {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
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 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 {}
|
// for {}
|
||||||
//
|
//
|
||||||
// let square = match tile {
|
// let square = match tile {
|
||||||
|
@ -85,8 +93,14 @@ impl fmt::Display for Board {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::Board;
|
||||||
|
use crate::BoardSize;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn setup_international_board() {
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
|
let expected = r#" ABCDEFGHIJ
|
||||||
|
"#;
|
||||||
|
assert_eq!(Board::new(BoardSize::International).to_string(), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue