tests(AllowLeadingHyphen): adds test issue 588 AllowLeadingHyphen not recognizing valid args

This commit is contained in:
Kevin K 2016-09-12 23:26:49 -04:00
parent 1ea9bef20d
commit 5c29448d54
No known key found for this signature in database
GPG key ID: 64FA5B74693EE1E5

View file

@ -263,6 +263,20 @@ fn delim_values_trailingvararg_with_delim() {
assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["test", "--foo", "-Wl", "-bar"]);
}
#[test]
fn leading_hyphen() {
let res = App::new("leadhy")
.setting(AppSettings::AllowLeadingHyphen)
.arg(Arg::with_name("some"))
.arg(Arg::with_name("other")
.short("o"))
.get_matches_from_safe(vec!["", "-bar", "-o"]);
assert!(res.is_ok(), "Error: {:?}", res.unwrap_err().kind);
let m = res.unwrap();
assert!(m.is_present("some"));
assert!(m.is_present("other"));
}
#[test]
fn leading_double_hyphen_trailingvararg() {
let m = App::new("positional")