From ef037eaf22a6c44abb8cee0df383f8019995ee73 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sun, 12 Mar 2017 12:53:40 -0400 Subject: [PATCH] tests: adds tests to check precedence of ArgRequiredElseHelp --- tests/app_settings.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/app_settings.rs b/tests/app_settings.rs index 644a863b..7f6b3f00 100644 --- a/tests/app_settings.rs +++ b/tests/app_settings.rs @@ -110,6 +110,18 @@ fn arg_required_else_help() { assert_eq!(err.kind, ErrorKind::MissingArgumentOrSubcommand); } +#[test] +fn arg_required_else_help_over_reqs() { + let result = App::new("arg_required") + .setting(AppSettings::ArgRequiredElseHelp) + .arg(Arg::with_name("test") + .index(1).required(true)) + .get_matches_from_safe(vec![""]); + assert!(result.is_err()); + let err = result.err().unwrap(); + assert_eq!(err.kind, ErrorKind::MissingArgumentOrSubcommand); +} + #[cfg(not(feature = "suggestions"))] #[test] fn infer_subcommands_fail_no_args() {