From c9c80b974c575c86725ac1eff457dbe9a1d4dede Mon Sep 17 00:00:00 2001 From: projectmoon Date: Thu, 17 Dec 2020 21:14:43 +0000 Subject: [PATCH] Tests for dice pool formatting. --- src/cofd/dice.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/cofd/dice.rs b/src/cofd/dice.rs index 4c4cc78..8251e50 100644 --- a/src/cofd/dice.rs +++ b/src/cofd/dice.rs @@ -689,4 +689,32 @@ mod tests { fmt_rolls(&result) ); } + + #[test] + fn shows_more_than_10_dice_test() { + //Make sure we display more than 10 dice when below the display limit (15). + let result = DicePoolRoll { + modifiers: DicePoolModifiers::default(), + rolls: vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], + }; + + assert_eq!( + "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14", + fmt_rolls(&result) + ); + } + + #[test] + fn shows_exactly_15_dice_test() { + //If we are at format limit (15), make sure all are shown + let result = DicePoolRoll { + modifiers: DicePoolModifiers::default(), + rolls: vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + }; + + assert_eq!( + "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15", + fmt_rolls(&result) + ); + } }