diff --git a/src/main.rs b/src/main.rs index 331c6fc731f5b0bf1a8a87bd25acc1cbd24b7eda..c17d377862869dfea67b5a804a00fdfa93908b96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,3 +55,36 @@ fn main() { board.display(); } + +// Will only be build in 'test' configuration +#[cfg(test)] +// A module where the tests are located, more on modules later +mod tests { + use super::*; + + #[test] + fn should_pass() { + assert!(true); + } + #[test] + #[should_panic] + fn should_panic() { + panic!("Doing wrong things on purpose here!"); + } + + #[test] + fn new_board_squares_are_empty() { + let board = Board::new(); + + for square in board.board { + + // Cannot do that due to 'trait' issues, more on that + // later + // assert_eq!(square, Square::Empty); + match square { + Square::Empty => (), + Square::Cross | Square::Circle => panic!("Square is not empty"), + } + } + } +}