Skip to content

Commit

Permalink
tests: adds tests for values when delims have been turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed Jan 28, 2016
1 parent 508db85 commit 4067311
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/multiple_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,43 @@ fn multiple_values_different_sep_positional() {
assert_eq!(m.occurrences_of("option"), 1);
assert_eq!(m.values_of("option").unwrap().collect::<Vec<_>>(), ["val1", "val2", "val3"]);
}

#[test]
fn multiple_values_no_sep() {
let m = App::new("multiple_values")
.arg(Arg::with_name("option")
.long("option")
.help("multiple options")
.takes_value(true)
.use_delimiter(false))
.get_matches_from_safe(vec![
"",
"--option=val1,val2,val3",
]);

assert!(m.is_ok());
let m = m.unwrap();

assert!(m.is_present("option"));
assert_eq!(m.occurrences_of("option"), 1);
assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
}

#[test]
fn multiple_values_no_sep_positional() {
let m = App::new("multiple_values")
.arg(Arg::with_name("option")
.help("multiple options")
.use_delimiter(false))
.get_matches_from_safe(vec![
"",
"val1,val2,val3",
]);

assert!(m.is_ok());
let m = m.unwrap();

assert!(m.is_present("option"));
assert_eq!(m.occurrences_of("option"), 1);
assert_eq!(m.value_of("option").unwrap(), "val1,val2,val3");
}

0 comments on commit 4067311

Please sign in to comment.