Skip to content
Snippets Groups Projects
Commit 8d759cce authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Add tests

parent 1d9c528d
Branches
Tags 05-unit-tests
No related merge requests found
...@@ -55,3 +55,36 @@ fn main() { ...@@ -55,3 +55,36 @@ fn main() {
board.display(); 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"),
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment