mirror of
https://github.com/clap-rs/clap
synced 2024-11-12 23:57:10 +00:00
test: adds tests for required_unless_one cases
This commit is contained in:
parent
1fc3b55bd6
commit
625cbbca0d
1 changed files with 23 additions and 0 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue