From 0996557a530692d276fd247995523344bfae084a Mon Sep 17 00:00:00 2001 From: Pavel Belikov Date: Sat, 18 Nov 2017 15:54:08 +0300 Subject: add ActionFlag --- test.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test.cxx') diff --git a/test.cxx b/test.cxx index 1189f97..5f97c87 100644 --- a/test.cxx +++ b/test.cxx @@ -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 &arg) { s = arg[0] + arg[1]; }); + + p.ParseArgs(std::vector{"-x"}); + REQUIRE(s == "flag"); + + p.ParseArgs(std::vector{"-y", "a"}); + REQUIRE(s == "a"); + + p.ParseArgs(std::vector{"-z", "a", "b"}); + REQUIRE(s == "ab"); +} + #undef ARGS_HXX #define ARGS_TESTNAMESPACE #define ARGS_NOEXCEPT -- cgit v1.2.1