mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
Added unit test for 2 mutex_groups
This commit is contained in:
parent
8f70dde82e
commit
7bbde0defb
@ -51,4 +51,21 @@ TEST_CASE("Create mutually exclusive group with 3 arguments" *
|
|||||||
program.parse_args({"test", "--first", "1", "--third", "2"}),
|
program.parse_args({"test", "--first", "1", "--third", "2"}),
|
||||||
"Argument '--third VAR' not allowed with '--first VAR'",
|
"Argument '--third VAR' not allowed with '--first VAR'",
|
||||||
std::runtime_error);
|
std::runtime_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Create two mutually exclusive groups" * test_suite("mutex_args")) {
|
||||||
|
argparse::ArgumentParser program("test");
|
||||||
|
|
||||||
|
auto &group_1 = program.add_mutually_exclusive_group();
|
||||||
|
group_1.add_argument("--first");
|
||||||
|
group_1.add_argument("--second");
|
||||||
|
group_1.add_argument("--third");
|
||||||
|
|
||||||
|
auto &group_2 = program.add_mutually_exclusive_group();
|
||||||
|
group_2.add_argument("-a");
|
||||||
|
group_2.add_argument("-b");
|
||||||
|
|
||||||
|
REQUIRE_THROWS_WITH_AS(
|
||||||
|
program.parse_args({"test", "--first", "1", "-a", "2", "-b", "3"}),
|
||||||
|
"Argument '-b VAR' not allowed with '-a VAR'", std::runtime_error);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user