tests: adds tests to guard against options with default values and zero or more values

This commit is contained in:
Kevin K 2017-09-14 10:18:45 -07:00
parent 9c248cbf7d
commit e1319fa198
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -392,4 +392,21 @@ fn issue_665() {
assert!(res.is_err());
assert_eq!(res.unwrap_err().kind, ErrorKind::EmptyValue);
}
#[test]
fn issue_1047_min_zero_vals_default_val() {
let m = App::new("foo")
.arg(
Arg::with_name("del")
.short("d")
.long("del")
.takes_value(true)
.require_equals(true)
.min_values(0)
.default_value("default"),
)
.get_matches_from(vec!["foo", "-d"]);
assert_eq!(m.occurrences_of("del"), 1);
assert_eq!(m.value_of("del"), Some("default"));
}