mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
Added another unit test for optional argument error reporting
This commit is contained in:
parent
c6e64ae36d
commit
7a3e0f1cb3
@ -35,6 +35,32 @@ TEST_CASE("Missing optional argument name" * test_suite("error_reporting")) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Missing optional argument name (some flag arguments)" * test_suite("error_reporting")) {
|
||||
argparse::ArgumentParser parser("test");
|
||||
parser.add_argument("-a").flag();
|
||||
parser.add_argument("-b").flag();
|
||||
parser.add_argument("-c");
|
||||
parser.add_argument("-d");
|
||||
|
||||
SUBCASE("Good case") {
|
||||
REQUIRE_NOTHROW(parser.parse_args({"test", "-a", "-b", "-c", "2"}));
|
||||
}
|
||||
|
||||
SUBCASE("Bad case") {
|
||||
REQUIRE_THROWS_WITH_AS(
|
||||
parser.parse_args({"test", "-a", "-b", "2"}),
|
||||
"Zero positional arguments expected, did you mean -c VAR",
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
SUBCASE("Bad case 2") {
|
||||
REQUIRE_THROWS_WITH_AS(
|
||||
parser.parse_args({"test", "-abc", "1", "2"}),
|
||||
"Zero positional arguments expected, did you mean -d VAR",
|
||||
std::runtime_error);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Missing optional argument name (multiple names)" *
|
||||
test_suite("error_reporting")) {
|
||||
argparse::ArgumentParser parser("test");
|
||||
|
Loading…
Reference in New Issue
Block a user