Skip to content

Commit

Permalink
Add test for dart parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
fxwiegand committed Apr 15, 2022
1 parent 4a40c7b commit 44d99ec
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/checkouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pub(crate) fn get_checkouts() -> HashMap<u16, Throw> {

#[cfg(test)]
mod tests {
use crate::checkouts::get_checkouts;
use crate::checkouts::{get_checkouts, Dart, Region};
use std::str::FromStr;

#[test]
fn test_checkout_validity() {
Expand All @@ -96,4 +97,20 @@ mod tests {
assert_eq!(score, throw._score())
}
}

#[test]
fn test_darts_from_str() {
assert_eq!(
Dart {
field: 20,
region: Region::Double
},
Dart::from_str("D20").unwrap()
)
}

#[test]
fn test_darts_from_str_err() {
assert!(Dart::from_str("Q20").is_err())
}
}

0 comments on commit 44d99ec

Please sign in to comment.