mirror of
https://github.com/clap-rs/clap
synced 2024-11-12 23:57:10 +00:00
Add a test
This commit is contained in:
parent
312432a5db
commit
cdb184b76c
1 changed files with 18 additions and 0 deletions
|
@ -204,3 +204,21 @@ fn conflicts_with_invalid_arg() {
|
|||
)
|
||||
.try_get_matches_from(vec!["", "--config"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conflicts_with_default() {
|
||||
let result = App::new("conflict")
|
||||
.arg(
|
||||
Arg::from("-o, --opt=[opt] 'some opt'")
|
||||
.default_value("default")
|
||||
.conflicts_with("flag"),
|
||||
)
|
||||
.arg(Arg::from("-f, --flag 'some flag'").conflicts_with("opt"))
|
||||
.try_get_matches_from(vec!["myprog", "-f"]);
|
||||
|
||||
assert!(result.is_ok(), "{:?}", result.unwrap());
|
||||
let m = result.unwrap();
|
||||
|
||||
assert_eq!(m.value_of("opt"), Some("default"));
|
||||
assert!(m.is_present("flag"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue