mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
tests(App): adds print_help test
This commit is contained in:
parent
c92a98fb67
commit
f9c04aeb2c
1 changed files with 30 additions and 0 deletions
|
@ -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 <opt> some option"));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue