Skip to content

Commit

Permalink
tests: adds tests to make sure args with default values can have conf…
Browse files Browse the repository at this point in the history
…licts
  • Loading branch information
kbknapp committed Oct 24, 2017
1 parent 58b5b4b commit f7a6955
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@ fn conflict_output() {
fn conflict_output_rev() {
test::compare_output(test::complex_app(), "clap-test val1 -F --long-option-2 val2 --flag", CONFLICT_ERR_REV, true);
}

#[test]
fn conflict_with_unused_default_value() {
let result = App::new("conflict")
.arg(Arg::from_usage("-o, --opt=[opt] 'some opt'")
.default_value("default"))
.arg(Arg::from_usage("-f, --flag 'some flag'")
.conflicts_with("opt"))
.get_matches_from_safe(vec!["myprog", "-f"]);
assert!(result.is_ok());
let m = result.unwrap();
assert_eq!(m.value_of("opt"), Some("default"));
assert!(m.is_present("flag"));
}

0 comments on commit f7a6955

Please sign in to comment.