diff --git a/src/combinators.rs b/src/combinators.rs index 5f2fe80..e0f7fc5 100644 --- a/src/combinators.rs +++ b/src/combinators.rs @@ -220,5 +220,24 @@ mod tests { p.parse("garb garb garb garb").unwrap(), (vec![20, 20, 20, 20], "") ); + + assert!(p.parse("garb garb garb garb ").is_err()); + + let p = + repeated(literal("garb").to(20)).separated_by(repeated(literal(" ")).at_least(1), true); + + assert_eq!( + p.parse("garb garb garb garb").unwrap(), + (vec![20, 20, 20, 20], "") + ); + + assert_eq!( + p.parse("garb garb garb garb ").unwrap(), + (vec![20, 20, 20, 20], "") + ); + assert_eq!( + p.parse("garb garb garb garb q").unwrap(), + (vec![20, 20, 20, 20], "q") + ); } }