From cdb184b76c88e6f324e72e9a4505e6bf7d7cafac Mon Sep 17 00:00:00 2001 From: CreepySkeleton Date: Sun, 26 Apr 2020 20:48:08 +0300 Subject: [PATCH] Add a test --- tests/conflicts.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/conflicts.rs b/tests/conflicts.rs index fc5765ee..e2ace81e 100644 --- a/tests/conflicts.rs +++ b/tests/conflicts.rs @@ -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")); +}