diff options
author | Taylor C. Richberger <taywee@gmx.com> | 2019-06-25 14:01:10 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-25 14:01:10 -0600 |
commit | 401663c1d57006566db6d8e5b37a21018fbd0bc3 (patch) | |
tree | b1ed4402bd951afe4dbc59613274321dd35a3bd2 /test.cxx | |
parent | Merge pull request #76 from pavel-belikov/fix-default-value-parser (diff) | |
parent | Fixes #74 : Fix group validation in Subparser/Command (diff) | |
download | args.hxx-401663c1d57006566db6d8e5b37a21018fbd0bc3.tar.xz |
Merge pull request #77 from pavel-belikov/subparser-group-validation
Fix group validation in Subparser/Command
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -936,6 +936,25 @@ TEST_CASE("Subparser validation works as expected", "[args]") REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"unknown-command"}), args::ParseError); } +TEST_CASE("Subparser group validation works as expected", "[args]") +{ + int x = 0; + args::ArgumentParser p("parser"); + args::Command a(p, "a", "command a", [&](args::Subparser &s) + { + args::Group required(s, "", args::Group::Validators::All); + args::ValueFlag<std::string> f(required, "", "", {'f'}); + s.Parse(); + ++x; + }); + + p.RequireCommand(false); + REQUIRE_NOTHROW(p.ParseArgs(std::vector<std::string>{})); + REQUIRE_NOTHROW(p.ParseArgs(std::vector<std::string>{"a", "-f", "F"})); + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"a"}), args::ValidationError); + REQUIRE(x == 1); +} + TEST_CASE("Global options work as expected", "[args]") { args::Group globals; |