diff options
author | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-12 16:45:02 +0300 |
---|---|---|
committer | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-12 16:59:19 +0300 |
commit | a86c29be5bb206420aa7520633782c7fc6c1b4db (patch) | |
tree | ebafc5ef3313e0b1e25ddb451adf6126fe973eef /test.cxx | |
parent | add HelpParams::proglineShowFlags (diff) | |
download | args.hxx-a86c29be5bb206420aa7520633782c7fc6c1b4db.tar.xz |
add Matcher validation tests
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -958,6 +958,12 @@ TEST_CASE("GetProgramLine works as expected", "[args]") REQUIRE(line(b) == "b -f <STRING> [positional]"); } +TEST_CASE("Matcher validation works as expected", "[args]") +{ + args::ArgumentParser parser("Test command"); + REQUIRE_THROWS_AS(args::ValueFlag<int>(parser, "", "", {}), args::UsageError); +} + #undef ARGS_HXX #define ARGS_TESTNAMESPACE #define ARGS_NOEXCEPT @@ -1088,6 +1094,17 @@ TEST_CASE("Nargs work as expected in noexcept mode", "[args]") argstest::ArgumentParser parser("Test command"); argstest::NargsValueFlag<int> a(parser, "", "", {'a'}, {3, 2}); + REQUIRE(parser.GetError() == argstest::Error::Usage); + parser.ParseArgs(std::vector<std::string>{"-a", "1", "2"}); + REQUIRE(parser.GetError() == argstest::Error::Usage); +} + +TEST_CASE("Matcher validation works as expected in noexcept mode", "[args]") +{ + argstest::ArgumentParser parser("Test command"); + argstest::ValueFlag<int> a(parser, "", "", {}); + + REQUIRE(parser.GetError() == argstest::Error::Usage); parser.ParseArgs(std::vector<std::string>{"-a", "1", "2"}); REQUIRE(parser.GetError() == argstest::Error::Usage); } |