mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
test(parser): Verify existing --flag=bad-value case
This commit is contained in:
parent
f925ca84b6
commit
3a8d2a579b
1 changed files with 18 additions and 0 deletions
|
@ -136,6 +136,24 @@ fn multiple_flags_in_single() {
|
||||||
assert!(*m.get_one::<bool>("debug").expect("defaulted by clap"));
|
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]
|
#[test]
|
||||||
#[cfg(feature = "error-context")]
|
#[cfg(feature = "error-context")]
|
||||||
fn issue_1284_argument_in_flag_style() {
|
fn issue_1284_argument_in_flag_style() {
|
||||||
|
|
Loading…
Reference in a new issue