From c83a559df1f93b0999ff066891b8ac161fd48930 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Wed, 5 Apr 2017 00:57:40 -0400 Subject: [PATCH] tests(clap_app!): adds tests for ("config-file") style positonal args --- tests/macros.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/macros.rs b/tests/macros.rs index cc25e1bf..035983bb 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -110,3 +110,40 @@ fn quoted_arg_long_name() { .expect("Expected to successfully match the given args."); assert!(matches.is_present("option2")); } + +#[test] +fn quoted_arg_name() { + let app = clap_app!(claptests => + (version: "0.1") + (about: "tests clap library") + (author: "Kevin K. ") + (@arg opt: -o --option +takes_value ... "tests options") + (@arg ("positional-arg"): index(1) "tests positionals") + (@arg flag: -f --flag ... +global "tests flags") + (@arg flag2: -F conflicts_with[flag] requires[option2] + "tests flags with exclusions") + (@arg option2: --("long-option-2") conflicts_with[option] requires[positional2] + "tests long options with exclusions") + (@arg positional2: index(2) "tests positionals with exclusions") + (@arg option3: -O --Option +takes_value possible_value[fast slow] + "tests options with specific value sets") + (@arg ("positional-3"): index(3) ... possible_value[vi emacs] + "tests positionals with specific values") + (@arg multvals: --multvals +takes_value value_name[one two] + "Tests mutliple values, not mult occs") + (@arg multvalsmo: --multvalsmo ... +takes_value value_name[one two] + "Tests mutliple values, not mult occs") + (@arg minvals: --minvals2 min_values(1) ... +takes_value "Tests 2 min vals") + (@arg maxvals: --maxvals3 ... +takes_value max_values(3) "Tests 3 max vals") + (@subcommand subcmd => + (about: "tests subcommands") + (version: "0.1") + (author: "Kevin K. ") + (@arg scoption: -o --option ... +takes_value "tests options") + (@arg scpositional: index(1) "tests positionals")) + ); + + let matches = app.get_matches_from_safe(vec!["bin_name", "value1", "value2", "--long-option-2"]) + .expect("Expected to successfully match the given args."); + assert!(matches.is_present("option2")); +}