Add test for whitespace.
@@ -110,6 +110,13 @@ mod tests {
assert_eq!(parse_dice_string("3d6-2").unwrap(), DiceType::new(3, 6, -2));
}
+ #[test]
+ fn parse_whitespace_test() {
+ assert_eq!(parse_dice_string("3d6 - 2").unwrap(), DiceType::new(3, 6, -2));
+ assert_eq!(parse_dice_string(" 3d6- 2").unwrap(), DiceType::new(3, 6, -2));
+ assert_eq!(parse_dice_string("3 d 6- 2").unwrap(), DiceType::new(3, 6, -2));
+ }
+
#[test]
fn fail_parsing() {
assert!(parse_dice_string("blah").is_err());
