Skip to content

Commit f9c04ae

Browse files
committed
tests(App): adds print_help test
1 parent c92a98f commit f9c04ae

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/app/app.rs

+30
Original file line numberDiff line numberDiff line change
@@ -3491,3 +3491,33 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
34913491
}
34923492

34933493
}
3494+
3495+
#[cfg(test)]
3496+
mod test {
3497+
use super::App;
3498+
3499+
#[test]
3500+
fn print_app_help() {
3501+
let app = App::new("test")
3502+
.author("Kevin K.")
3503+
.about("tests stuff")
3504+
.args_from_usage("-f, --flag 'some flag'
3505+
--option [opt] 'some option'");
3506+
let mut help = vec![];
3507+
app.print_help(&mut help).ok().expect("failed to print help");
3508+
assert_eq!(String::from_utf8_lossy(help), String::from("test
3509+
Kevin K.
3510+
tests stuff
3511+
3512+
USAGE:
3513+
fake [FLAGS] [OPTIONS] [SUBCOMMAND]
3514+
3515+
FLAGS:
3516+
-f, --flag some flag
3517+
-h, --help Prints help information
3518+
-V, --version Prints version information
3519+
3520+
OPTIONS:
3521+
--option <opt> some option"));
3522+
}
3523+
}

0 commit comments

Comments
 (0)