use crate::*;
#[test]
fn success() {
let parser1 = is("hello");
let parser2 = is("hallo");
let parser3 = is("hillo");
let parsers: Vec<Box<dyn Parser<_, _>>> =
vec![Box::new(parser1), Box::new(parser2), Box::new(parser3)];
let parser_choice = choice(&parsers);
let tokens = vec!["hello"];
let mut input = Input::new(tokens);
let output = parser_choice(&mut input).unwrap();
assert_eq!(output, "hello");
assert!(end_of_input()(&mut input).is_ok()); let tokens = vec!["hallo"];
let mut input = Input::new(tokens);
let output = parser_choice(&mut input).unwrap();
assert_eq!(output, "hallo");
assert!(end_of_input()(&mut input).is_ok()); let tokens = vec!["hillo"];
let mut input = Input::new(tokens);
let output = parser_choice(&mut input).unwrap();
assert_eq!(output, "hillo");
assert!(end_of_input()(&mut input).is_ok()); let tokens = vec!["hullo"];
let mut input = Input::new(tokens);
assert_eq!(parser_choice(&mut input), Err(Error::UnexpectedToken));
assert!(end_of_input()(&mut input).is_err()); }
#[test]
fn fail() {
let parser1 = is("hello");
let parser2 = is("hallo");
let parser3 = is("hillo");
let parsers: Vec<Box<dyn Parser<_, _>>> =
vec![Box::new(parser1), Box::new(parser2), Box::new(parser3)];
let parser_choice = choice(&parsers);
let tokens = vec!["hullo"];
let mut input = Input::new(tokens);
let output = parser_choice(&mut input);
assert_eq!(output, Err(Error::UnexpectedToken));
assert!(end_of_input()(&mut input).is_err()); }