Skip to content

Commit

Permalink
test(parser): Show one value terminator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 21, 2023
1 parent 727ca29 commit bdf205b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/builder/multiple_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,39 @@ fn multiple_value_terminator_option_other_arg() {
assert!(*m.get_one::<bool>("flag").expect("defaulted by clap"));
}

#[test]
fn all_multiple_value_terminator() {
let m = Command::new("lip")
.arg(
Arg::new("files")
.value_terminator(";")
.action(ArgAction::Set)
.num_args(0..),
)
.arg(Arg::new("other").num_args(0..))
.try_get_matches_from(vec!["test", "value", ";"]);

assert!(m.is_ok(), "{:?}", m.unwrap_err().kind());
let m = m.unwrap();

assert!(m.contains_id("files"));
assert!(m.contains_id("other"));
assert_eq!(
m.get_many::<String>("files")
.unwrap()
.map(|v| v.as_str())
.collect::<Vec<_>>(),
["value".to_owned()],
);
assert_eq!(
m.get_many::<String>("other")
.unwrap()
.map(|v| v.as_str())
.collect::<Vec<_>>(),
[";".to_owned()],
);
}

#[test]
fn multiple_vals_with_hyphen() {
let res = Command::new("do")
Expand Down

0 comments on commit bdf205b

Please sign in to comment.