diff options
author | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-18 15:54:08 +0300 |
---|---|---|
committer | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-18 15:54:08 +0300 |
commit | 0996557a530692d276fd247995523344bfae084a (patch) | |
tree | 06e46cad4159bbe0b9fc93b4865c338114e4312e /test.cxx | |
parent | Merge pull request #43 from pavel-belikov/better-help (diff) | |
download | args.hxx-0996557a530692d276fd247995523344bfae084a.tar.xz |
add ActionFlag
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1066,6 +1066,25 @@ TEST_CASE("HelpParams work as expected", "[args]") } +TEST_CASE("ActionFlag works as expected", "[args]") +{ + args::ArgumentParser p("parser"); + std::string s; + + args::ActionFlag action0(p, "name", "description", {'x'}, [&]() { s = "flag"; }); + args::ActionFlag action1(p, "name", "description", {'y'}, [&](const std::string &arg) { s = arg; }); + args::ActionFlag actionN(p, "name", "description", {'z'}, 2, [&](const std::vector<std::string> &arg) { s = arg[0] + arg[1]; }); + + p.ParseArgs(std::vector<std::string>{"-x"}); + REQUIRE(s == "flag"); + + p.ParseArgs(std::vector<std::string>{"-y", "a"}); + REQUIRE(s == "a"); + + p.ParseArgs(std::vector<std::string>{"-z", "a", "b"}); + REQUIRE(s == "ab"); +} + #undef ARGS_HXX #define ARGS_TESTNAMESPACE #define ARGS_NOEXCEPT |