Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Aug 9, 2021
1 parent d38aab1 commit 2619b5a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/game/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ mod test {

use pretty_assertions::assert_eq;

#[test]
fn clock_struct() {
let clock: Clock = Clock {
black: Duration::from_secs(3600),
white: Duration::from_secs(1800),
};
assert_eq!(clock.black, Duration::from_secs(3600));
assert_eq!(clock.white, Duration::from_secs(1800));
}

#[test]
fn new_clock() {
let clock: Clock = Clock::new(Duration::from_secs(3600), Duration::from_secs(1800));
Expand Down
8 changes: 8 additions & 0 deletions src/game/metadata/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ mod test {

#[test]
fn location() {
let location: Location = Location {
city: "moimacco".to_string(),
region: "friuli-venezia giulia".to_string(),
country: Country::Italy,
};
assert_eq!(location.city(), "moimacco");
assert_eq!(location.country(), Country::Italy);
assert_eq!(location.region(), "friuli-venezia giulia");
let location: Location = Location::new("moimacco", "friuli-venezia giulia", Country::Italy);
assert_eq!(location.city(), "moimacco");
assert_eq!(location.country(), Country::Italy);
Expand Down
16 changes: 16 additions & 0 deletions src/game/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,22 @@ mod test {
assert_eq!(metadata.round, None);
assert_eq!(metadata.site, None);
assert_eq!(metadata.white, None);
let metadata: Metadata = Metadata {
black: None,
date: None,
event: None,
result: Result::Unknown,
round: None,
site: None,
white: None,
};
assert_eq!(metadata.black, None);
assert_eq!(metadata.date, None);
assert_eq!(metadata.event, None);
assert_eq!(metadata.result, Result::Unknown);
assert_eq!(metadata.round, None);
assert_eq!(metadata.site, None);
assert_eq!(metadata.white, None);
}

#[test]
Expand Down
12 changes: 12 additions & 0 deletions src/game/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ mod test {

#[test]
fn game_move() {
let m: GameMove = GameMove {
itself: Move::Resign,
turn: 2,
time: Duration::from_secs(5),
piece_taken: None,
promotion: None,
};
assert_eq!(m.itself, Move::Resign);
assert_eq!(m.turn, 2);
assert_eq!(m.time, Duration::from_secs(5));
assert_eq!(m.piece_taken, None);
assert_eq!(m.promotion, None);
let m: GameMove = GameMove::new(Move::Resign, 2, Duration::from_secs(5), None, None);
assert_eq!(m.itself, Move::Resign);
assert_eq!(m.turn, 2);
Expand Down

0 comments on commit 2619b5a

Please sign in to comment.