mirror of
https://github.com/clap-rs/clap
synced 2024-11-12 23:57:10 +00:00
tests(help): add tests for help subcommand
This commit is contained in:
parent
113ed0284e
commit
44cbed1a2a
1 changed files with 28 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
extern crate clap;
|
||||
|
||||
use clap::{App, ClapErrorType};
|
||||
use clap::{App, SubCommand, ClapErrorType};
|
||||
|
||||
#[test]
|
||||
fn help_short() {
|
||||
|
@ -26,6 +26,33 @@ fn help_long() {
|
|||
assert_eq!(m.unwrap_err().error_type, ClapErrorType::HelpDisplayed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_no_subcommand() {
|
||||
let m = App::new("test")
|
||||
.author("Kevin K.")
|
||||
.about("tests stuff")
|
||||
.version("1.3")
|
||||
.get_matches_from_safe(vec!["", "help"]);
|
||||
|
||||
assert!(m.is_err());
|
||||
assert_eq!(m.unwrap_err().error_type, ClapErrorType::UnexpectedArgument);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_subcommand() {
|
||||
let m = App::new("test")
|
||||
.author("Kevin K.")
|
||||
.about("tests stuff")
|
||||
.version("1.3")
|
||||
.subcommand(SubCommand::with_name("test")
|
||||
.about("tests things")
|
||||
.arg_from_usage("-v --verbose 'with verbosity'"))
|
||||
.get_matches_from_safe(vec!["", "help"]);
|
||||
|
||||
assert!(m.is_err());
|
||||
assert_eq!(m.unwrap_err().error_type, ClapErrorType::HelpDisplayed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_app_help() {
|
||||
let mut app = App::new("test")
|
||||
|
|
Loading…
Reference in a new issue