Skip to content

Commit

Permalink
test(parser): Verify existing --flag=bad-value case
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 27, 2022
1 parent f925ca8 commit 3a8d2a5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/builder/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3a8d2a5

Please sign in to comment.