summaryrefslogtreecommitdiff
path: root/src/dice.rs
diff options
context:
space:
mode:
authorArne Dußin2021-04-26 13:54:49 +0200
committerArne Dußin2021-04-26 13:54:49 +0200
commitc33b623e4117a1c3cfa1a14c38c2e5ab3f81f7f4 (patch)
tree200e926429e0a98540a09f46addfff7c7f7692b9 /src/dice.rs
parent13e4cdf7b4b4d12834e4039419a0e470a3291fd4 (diff)
downloadcappuccino-c33b623e4117a1c3cfa1a14c38c2e5ab3f81f7f4.tar.gz
cappuccino-c33b623e4117a1c3cfa1a14c38c2e5ab3f81f7f4.zip
Add additional dice tests and skip tests for rngsHEADmain
Diffstat (limited to 'src/dice.rs')
-rw-r--r--src/dice.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/dice.rs b/src/dice.rs
index 68b6ecf..a2774d6 100644
--- a/src/dice.rs
+++ b/src/dice.rs
@@ -58,6 +58,7 @@ impl Die
pub fn value(&self) -> u8 { DIE_VALUES[self.0 as usize] }
+ #[tarpaulin::skip]
pub fn roll(&self) -> u8
{
let mut rng = rand::thread_rng();
@@ -115,6 +116,7 @@ impl RiskDie
/// Roll the die. If the die shows 3 or less, it returns the next lower die.
/// If it is more, it returns itself. If it was already the lowest die value
/// and it would be stepped down it returns `None`.
+ #[tarpaulin::skip]
pub fn roll(self) -> Option<Self>
{
let mut rng = rand::thread_rng();
@@ -210,6 +212,14 @@ mod tests
}
#[test]
+ fn create_risk_die_from_invalid_value()
+ {
+ assert_eq!(RiskDie::from_value(5), Err(Error::InvalidValue));
+ assert_eq!(RiskDie::from_value(21), Err(Error::InvalidValue));
+ assert_eq!(RiskDie::from_value(0), Err(Error::InvalidValue));
+ }
+
+ #[test]
fn risk_die_level_down()
{
assert_eq!(DELTA_4.level_down(), None);
@@ -232,6 +242,28 @@ mod tests
}
#[test]
+ fn risk_die_can_be_lowered()
+ {
+ assert!(!DELTA_4.can_be_lowered());
+ assert!(DELTA_6.can_be_lowered());
+ assert!(DELTA_8.can_be_lowered());
+ assert!(DELTA_10.can_be_lowered());
+ assert!(DELTA_12.can_be_lowered());
+ assert!(DELTA_20.can_be_lowered());
+ }
+
+ #[test]
+ fn risk_die_can_be_upped()
+ {
+ assert!(DELTA_4.can_be_upped());
+ assert!(DELTA_6.can_be_upped());
+ assert!(DELTA_8.can_be_upped());
+ assert!(DELTA_10.can_be_upped());
+ assert!(DELTA_12.can_be_upped());
+ assert!(!DELTA_20.can_be_upped());
+ }
+
+ #[test]
fn add_risk_dice()
{
assert_eq!(DELTA_4 + DELTA_4, DELTA_6);