diff --git a/test/test_choices.cpp b/test/test_choices.cpp index 206ec89..4fc4383 100644 --- a/test/test_choices.cpp +++ b/test/test_choices.cpp @@ -38,6 +38,24 @@ TEST_CASE("Parse argument that is in the fixed number of allowed choices, with " REQUIRE(program.get("--value") == 1); } +TEST_CASE( + "Parse nargs argument that is in the fixed number of allowed choices, with " + "other positional argument" * + test_suite("choices")) { + argparse::ArgumentParser program("test"); + program.add_argument("--input") + .default_value(std::string{"baz"}) + .choices("foo", "bar", "baz") + .nargs(2); + program.add_argument("--value").scan<'i', int>().default_value(0); + + REQUIRE_NOTHROW( + program.parse_args({"test", "--input", "foo", "bar", "--value", "1"})); + REQUIRE((program.get>("--input") == + std::vector{"foo", "bar"})); + REQUIRE(program.get("--value") == 1); +} + TEST_CASE("Parse argument that is in the fixed number of allowed choices, with " "other positional argument (reversed)" * test_suite("choices")) { @@ -53,6 +71,24 @@ TEST_CASE("Parse argument that is in the fixed number of allowed choices, with " REQUIRE(program.get("--value") == 1); } +TEST_CASE( + "Parse nargs argument that is in the fixed number of allowed choices, with " + "other positional argument (reversed)" * + test_suite("choices")) { + argparse::ArgumentParser program("test"); + program.add_argument("--input") + .default_value(std::string{"baz"}) + .choices("foo", "bar", "baz") + .nargs(2); + program.add_argument("--value").scan<'i', int>().default_value(0); + + REQUIRE_NOTHROW( + program.parse_args({"test", "--value", "1", "--input", "foo", "bar"})); + REQUIRE((program.get>("--input") == + std::vector{"foo", "bar"})); + REQUIRE(program.get("--value") == 1); +} + TEST_CASE("Parse argument that is in the fixed number of allowed choices, with " "invalid default" * test_suite("choices")) {