tests: adds tests to make sure args with default values can have conflicts

This commit is contained in:
Kevin K 2017-10-24 12:23:29 -07:00
parent 58b5b4be31
commit f7a6955238
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -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"));
}