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 <sean.robinson@scottsdalecc.edu>
This commit is contained in:
Sean Robinson 2021-07-22 06:45:44 -07:00
parent b33ba4fb5d
commit 67d56afef8

View File

@ -13,6 +13,15 @@ TEST_CASE("Parse positional arguments" * test_suite("positional_arguments")) {
REQUIRE(program.get("output") == "thrust_profile.csv"); 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_CASE("Parse positional arguments with fixed nargs" *
test_suite("positional_arguments")) { test_suite("positional_arguments")) {
argparse::ArgumentParser program("test"); argparse::ArgumentParser program("test");