Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
intro-rust-game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Hauspie
intro-rust-game
Commits
8d759cce
Commit
8d759cce
authored
2 years ago
by
Michael Hauspie
Browse files
Options
Downloads
Patches
Plain Diff
Add tests
parent
1d9c528d
Branches
Branches containing commit
Tags
05-unit-tests
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+33
-0
33 additions, 0 deletions
src/main.rs
with
33 additions
and
0 deletions
src/main.rs
+
33
−
0
View file @
8d759cce
...
@@ -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"
),
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment