diff options
author | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-18 15:57:51 +0300 |
---|---|---|
committer | Pavel Belikov <pavel.fuchs.belikov@gmail.com> | 2017-11-18 15:57:51 +0300 |
commit | ec3c42cdd95eba66d374994c7153e954c05b8f06 (patch) | |
tree | 6707c29a7ad974ce50f9e48644a67bacda83c14a /test.cxx | |
parent | add ActionFlag (diff) | |
download | args.hxx-ec3c42cdd95eba66d374994c7153e954c05b8f06.tar.xz |
add test for throwing exception from ActionFlag
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1074,6 +1074,7 @@ TEST_CASE("ActionFlag works as expected", "[args]") 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]; }); + args::ActionFlag actionThrow(p, "name", "description", {'v'}, [&]() { throw std::runtime_error(""); }); p.ParseArgs(std::vector<std::string>{"-x"}); REQUIRE(s == "flag"); @@ -1083,6 +1084,8 @@ TEST_CASE("ActionFlag works as expected", "[args]") p.ParseArgs(std::vector<std::string>{"-z", "a", "b"}); REQUIRE(s == "ab"); + + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"-v"}), std::runtime_error); } #undef ARGS_HXX |