From cc4c12e8fb7fc32821cc2f7f23267b24e67f7e83 Mon Sep 17 00:00:00 2001 From: CrazyMerlyn Date: Wed, 22 Mar 2017 15:44:02 +0530 Subject: [PATCH] tests(Help): adds tests for per argument hiding of default value --- tests/help.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/help.rs b/tests/help.rs index cd49ecf96cf..a3354dc5e7f 100644 --- a/tests/help.rs +++ b/tests/help.rs @@ -356,6 +356,18 @@ SUBCOMMANDS: help Prints this message or the help of the given subcommand(s) test some"; +static HIDE_DEFAULT_VAL: &'static str = "default 0.1 + +USAGE: + default [OPTIONS] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + --arg Pass an argument to the program. [default: default-argument]"; + #[test] fn help_short() { let m = App::new("test") @@ -750,4 +762,27 @@ fn last_arg_mult_usage_with_sc() { .arg(Arg::with_name("ARGS").multiple(true).last(true).help("some")) .subcommand(SubCommand::with_name("test").about("some")); assert!(test::compare_output(app, "last --help", LAST_ARG_SC, false)); -} \ No newline at end of file +} + + +#[test] +fn hidden_default_val() { + let app1 = App::new("default") + .version("0.1") + .set_term_width(120) + .arg(Arg::with_name("argument") + .help("Pass an argument to the program. [default: default-argument]") + .long("arg") + .default_value("default-argument") + .hide_default_value(true)); + assert!(test::compare_output(app1, "default --help", HIDE_DEFAULT_VAL, false)); + + let app2 = App::new("default") + .version("0.1") + .set_term_width(120) + .arg(Arg::with_name("argument") + .help("Pass an argument to the program.") + .long("arg") + .default_value("default-argument")); + assert!(test::compare_output(app2, "default --help", HIDE_DEFAULT_VAL, false)); +}