From f9c04aeb2c0b9a98366ccebb1d65165605be19d9 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Tue, 8 Sep 2015 21:03:20 -0400 Subject: [PATCH] tests(App): adds print_help test --- src/app/app.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/app/app.rs b/src/app/app.rs index bdbc6873..a96c19d1 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -3491,3 +3491,33 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ } } + +#[cfg(test)] +mod test { + use super::App; + + #[test] + fn print_app_help() { + let app = App::new("test") + .author("Kevin K.") + .about("tests stuff") + .args_from_usage("-f, --flag 'some flag' + --option [opt] 'some option'"); + let mut help = vec![]; + app.print_help(&mut help).ok().expect("failed to print help"); + assert_eq!(String::from_utf8_lossy(help), String::from("test +Kevin K. +tests stuff + +USAGE: + fake [FLAGS] [OPTIONS] [SUBCOMMAND] + +FLAGS: + -f, --flag some flag + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + --option some option")); + } +} \ No newline at end of file