Skip to content

Commit

Permalink
test: adds tests for required_unless_one cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed Jul 23, 2016
1 parent 1fc3b55 commit 625cbbc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/require.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 625cbbc

Please sign in to comment.