diff options
author | Taylor C. Richberger <taywee@gmx.com> | 2019-06-25 13:17:17 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-25 13:17:17 -0600 |
commit | b92191364de31abea947a201151f5a844a572e97 (patch) | |
tree | 544ed67d72e5849a65848bf20e3771c4cd0ae27d /test.cxx | |
parent | Merge pull request #73 from zhihaoy/cmake-targets (diff) | |
parent | Fixes #75 : Check istringstream state in ValueParser (diff) | |
download | args.hxx-b92191364de31abea947a201151f5a844a572e97.tar.xz |
Merge pull request #76 from pavel-belikov/fix-default-value-parser
Check istringstream state in ValueParser
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1173,6 +1173,8 @@ TEST_CASE("ValueParser works as expected", "[args]") args::ValueFlag<std::string> f(p, "name", "description", {'f'}); args::ValueFlag<StringAssignable> b(p, "name", "description", {'b'}); args::ValueFlag<int> i(p, "name", "description", {'i'}); + args::ValueFlag<int> d(p, "name", "description", {'d'}); + args::PositionalList<double> ds(p, "name", "description"); REQUIRE_NOTHROW(p.ParseArgs(std::vector<std::string>{"-f", "a b"})); REQUIRE(args::get(f) == "a b"); @@ -1185,6 +1187,11 @@ TEST_CASE("ValueParser works as expected", "[args]") REQUIRE_NOTHROW(p.ParseArgs(std::vector<std::string>{"-i", " 12"})); REQUIRE(args::get(i) == 12); + + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"-i", "a"}), args::ParseError); + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"-d", "b"}), args::ParseError); + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"c"}), args::ParseError); + REQUIRE_THROWS_AS(p.ParseArgs(std::vector<std::string>{"s"}), args::ParseError); } TEST_CASE("ActionFlag works as expected", "[args]") |