tests: adds tests for propogating values down

This commit is contained in:
Kevin K 2017-01-02 23:04:48 -05:00
parent 985536c8eb
commit c142fb544d
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -449,4 +449,17 @@ fn args_negate_subcommands_two_levels() {
assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind);
let m = res.unwrap();
assert_eq!(m.subcommand_matches("sub1").unwrap().value_of("arg2"), Some("sub2"));
}
#[test]
fn propagate_vals_down() {
let m = App::new("myprog")
.setting(AppSettings::PropagateGlobalValuesDown)
.arg(Arg::from_usage("[cmd] 'command to run'").global(true))
.subcommand(SubCommand::with_name("foo"))
.get_matches_from(vec!["myprog", "set", "foo"]);
assert_eq!(m.value_of("cmd"), Some("set"));
let sub_m = m.subcommand_matches("foo").unwrap();
assert_eq!(sub_m.value_of("cmd"), Some("set"));
}