From 67d56afef8cf11568f37a99a9f4eaf18285b2578 Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Thu, 22 Jul 2021 06:45:44 -0700 Subject: [PATCH] Add test case for missing expected positional argument This fills a tiny gap in the positional_arguments suite. Most existing tests have positional arguments. The one case without an argument uses Argument::remaining so that ArgumentParserArgument::parse_args does not throw, instead ArgumentParser::get<> throws std::logic_error. Signed-off-by: Sean Robinson --- test/test_positional_arguments.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test_positional_arguments.cpp b/test/test_positional_arguments.cpp index f0d936c..4e2489b 100644 --- a/test/test_positional_arguments.cpp +++ b/test/test_positional_arguments.cpp @@ -13,6 +13,15 @@ TEST_CASE("Parse positional arguments" * test_suite("positional_arguments")) { REQUIRE(program.get("output") == "thrust_profile.csv"); } +TEST_CASE("Missing expected positional argument" * + test_suite("positional_arguments")) { + argparse::ArgumentParser program("test"); + program.add_argument("input"); + REQUIRE_THROWS_WITH_AS(program.parse_args({ "test" }), + "1 argument(s) expected. 0 provided.", + std::runtime_error); +} + TEST_CASE("Parse positional arguments with fixed nargs" * test_suite("positional_arguments")) { argparse::ArgumentParser program("test");