diff --git a/tests/app_settings.rs b/tests/app_settings.rs index 0c963ce3dbf..79fc8fd74bb 100644 --- a/tests/app_settings.rs +++ b/tests/app_settings.rs @@ -827,6 +827,64 @@ fn aaos_opts() { assert_eq!(m.value_of("opt"), Some("other")); } +#[test] +fn aaos_opts_two_values() { + // opts with two values + let res = App::new("posix") + .setting(AppSettings::AllArgsOverrideSelf) + .arg(Arg::from("--opt [val1] [val2] 'some option'")) + .try_get_matches_from(vec![ + "", "--opt", "some", "thing", "--opt", "other", "stuff", + ]); + assert!(res.is_ok()); + let m = res.unwrap(); + assert!(m.is_present("opt")); + assert_eq!(m.occurrences_of("opt"), 1); + assert_eq!( + m.values_of("opt").unwrap().collect::>(), + &["other", "stuff"] + ); +} + +#[test] +fn aaos_opts_two_values_delimiter() { + // opts with two values and a delimiter + let res = App::new("posix") + .setting(AppSettings::AllArgsOverrideSelf) + .arg(Arg::from("--opt [val1] [val2] 'some option'").require_delimiter(true)) + .try_get_matches_from(vec!["", "--opt=some,thing", "--opt=other,stuff"]); + assert!(res.is_ok()); + let m = res.unwrap(); + assert!(m.is_present("opt")); + assert_eq!(m.occurrences_of("opt"), 1); + assert_eq!( + m.values_of("opt").unwrap().collect::>(), + &["other", "stuff"] + ); +} + +#[test] +fn aaos_opts_min_value() { + // opts with min_value + let res = App::new("posix") + .setting(AppSettings::AllArgsOverrideSelf) + .arg( + Arg::from("--opt [val] 'some option'") + .require_delimiter(true) + .min_values(0), + ) + .try_get_matches_from(vec!["", "--opt", "--opt=val1,val2"]); + assert!(res.is_ok()); + let m = res.unwrap(); + assert!(m.is_present("opt")); + assert_eq!(m.occurrences_of("opt"), 1); + assert_eq!( + m.values_of("opt").unwrap().collect::>(), + &["val1", "val2"] + ); +} + + #[test] fn aaos_opts_w_other_overrides() { // opts with other overrides