test: adds tests for required_unless_one cases

This commit is contained in:
Kevin K 2016-07-23 17:22:14 -04:00
parent 1fc3b55bd6
commit 625cbbca0d

View file

@ -303,6 +303,29 @@ fn required_unless_one_2() {
assert!(!m.is_present("cfg"));
}
#[test]
fn required_unless_one_1() {
let res = App::new("unlessone")
.arg(Arg::with_name("cfg")
.required_unless_one(&["dbg", "infile"])
.takes_value(true)
.long("config"))
.arg(Arg::with_name("dbg")
.long("debug"))
.arg(Arg::with_name("infile")
.short("i")
.takes_value(true))
.get_matches_from_safe(vec![
"unlessone", "--debug"
]);
assert!(res.is_ok());
let m = res.unwrap();
assert!(!m.is_present("infile"));
assert!(!m.is_present("cfg"));
assert!(m.is_present("dbg"));
}
#[test]
fn required_unless_one_err() {
let res = App::new("unlessone")