From c142fb544d60f8fbeba23221bf50d2395971e548 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Mon, 2 Jan 2017 23:04:48 -0500 Subject: [PATCH] tests: adds tests for propogating values down --- tests/app_settings.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/app_settings.rs b/tests/app_settings.rs index a495f84e..93614210 100644 --- a/tests/app_settings.rs +++ b/tests/app_settings.rs @@ -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")); } \ No newline at end of file