mirror of
https://github.com/clap-rs/clap
synced 2024-12-04 18:19:13 +00:00
test(parser): Show bad ignore_errors defaulting case
This commit is contained in:
parent
76d0049330
commit
6827841930
1 changed files with 21 additions and 0 deletions
|
@ -95,6 +95,27 @@ fn multiple_args_and_intermittent_arg_without_value() {
|
|||
assert_eq!(m.get_one::<bool>("unset-flag").copied(), Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unexpected_argument() {
|
||||
let cmd = Command::new("cmd")
|
||||
.ignore_errors(true)
|
||||
.arg(arg!(
|
||||
-c --config [FILE] "Sets a custom config file"
|
||||
))
|
||||
.arg(arg!(--"unset-flag"));
|
||||
|
||||
let r = cmd.try_get_matches_from(vec!["cmd", "-c", "config file", "unexpected"]);
|
||||
|
||||
assert!(r.is_ok(), "unexpected error: {r:?}");
|
||||
let m = r.unwrap();
|
||||
assert!(m.contains_id("config"));
|
||||
assert_eq!(
|
||||
m.get_one::<String>("config").cloned(),
|
||||
Some("config file".to_owned())
|
||||
);
|
||||
assert_eq!(m.get_one::<bool>("unset-flag").copied(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn subcommand() {
|
||||
let cmd = Command::new("test")
|
||||
|
|
Loading…
Reference in a new issue