From 8d759cce4662b692edda9ac66f46146a80d01762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Hauspie?= <michael.hauspie@univ-lille.fr> Date: Sun, 27 Nov 2022 18:10:55 +0100 Subject: [PATCH] Add tests --- src/main.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main.rs b/src/main.rs index 331c6fc..c17d377 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"), + } + } + } +} -- GitLab