mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 23:04:23 +00:00
tests: adds tests to make sure args with default values can have conflicts
This commit is contained in:
parent
58b5b4be31
commit
f7a6955238
1 changed files with 14 additions and 0 deletions
|
@ -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"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue