Add tests for 2229

This commit is contained in:
ldm0 2021-02-16 03:58:58 +00:00
parent 28b58af63b
commit 3873b647d1

View file

@ -1192,3 +1192,19 @@ fn issue_1480_max_values_consumes_extra_arg_3() {
assert!(res.is_err()); assert!(res.is_err());
assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument); assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
} }
#[test]
fn issue_2229() {
let m = App::new("multiple_values")
.arg(
Arg::new("pos")
.about("multiple positionals")
.number_of_values(3),
)
.try_get_matches_from(vec![
"myprog", "val1", "val2", "val3", "val4", "val5", "val6",
]);
assert!(m.is_err()); // This panics, because `m.is_err() == false`.
assert_eq!(m.unwrap_err().kind, ErrorKind::WrongNumberOfValues);
}