test(parser): Verify existing --flag=bad-value case

This commit is contained in:
Ed Page 2022-09-27 09:19:27 -05:00
parent f925ca84b6
commit 3a8d2a579b

View file

@ -136,6 +136,24 @@ fn multiple_flags_in_single() {
assert!(*m.get_one::<bool>("debug").expect("defaulted by clap"));
}
#[test]
#[cfg(feature = "error-context")]
fn unexpected_value_error() {
const USE_FLAG_AS_ARGUMENT: &str = "\
error: The value 'foo' was provided to '--a-flag' but it wasn't expecting any more values
mycat [OPTIONS] [filename]
For more information try '--help'
";
let cmd = Command::new("mycat")
.arg(Arg::new("filename"))
.arg(Arg::new("a-flag").long("a-flag").action(ArgAction::SetTrue));
utils::assert_output(cmd, "mycat --a-flag=foo", USE_FLAG_AS_ARGUMENT, true);
}
#[test]
#[cfg(feature = "error-context")]
fn issue_1284_argument_in_flag_style() {