From e1319fa1989c212b79d3b8abf86dab7c7e481e8c Mon Sep 17 00:00:00 2001 From: Kevin K Date: Thu, 14 Sep 2017 10:18:45 -0700 Subject: [PATCH] tests: adds tests to guard against options with default values and zero or more values --- tests/opts.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/opts.rs b/tests/opts.rs index 6dccb94b..8a2deee9 100644 --- a/tests/opts.rs +++ b/tests/opts.rs @@ -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")); } \ No newline at end of file