tests: adds tests for

This commit is contained in:
Kevin K 2016-12-30 22:40:28 -05:00
parent c2978afc61
commit 25cbca4e41
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -1,7 +1,24 @@
extern crate clap;
extern crate regex;
use clap::{App, Arg, SubCommand, AppSettings, ErrorKind};
include!("../clap-test.rs");
static DONT_COLLAPSE_ARGS: &'static str = "clap-test v1.4.8
USAGE:
clap-test [arg1] [arg2] [arg3]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<arg1> some
<arg2> some
<arg3> some";
#[test]
fn sub_command_negate_required() {
App::new("sub_command_negate")
@ -381,4 +398,17 @@ fn disable_help_subcommand() {
assert!(result.is_err());
let err = result.err().unwrap();
assert_eq!(err.kind, ErrorKind::UnknownArgument);
}
#[test]
fn dont_collapse_args() {
let app = App::new("clap-test")
.version("v1.4.8")
.setting(AppSettings::DontCollapseArgsInUsage)
.args(&[
Arg::with_name("arg1").help("some"),
Arg::with_name("arg2").help("some"),
Arg::with_name("arg3").help("some"),
]);
test::check_help(app, DONT_COLLAPSE_ARGS);
}