diff options
author | Taylor C. Richberger <Taywee@gmx.com> | 2016-07-16 03:44:22 -0600 |
---|---|---|
committer | Taylor C. Richberger <Taywee@gmx.com> | 2016-07-16 03:44:22 -0600 |
commit | 9bc4c477e39725d6031a601f5341363bcbf54646 (patch) | |
tree | 160f31e48f811c0653ab1e2b110b577988e05260 /test.cxx | |
parent | Merge branch 'master' of github.com:Taywee/args (diff) | |
download | args.hxx-9bc4c477e39725d6031a601f5341363bcbf54646.tar.xz |
fix many bugs, add tests for terminator6.0.1
Diffstat (limited to 'test.cxx')
-rw-r--r-- | test.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -162,6 +162,47 @@ TEST_CASE("Positional arguments and positional argument lists work as expected", REQUIRE((args::get(baz) == std::vector<char>{'a', 'b', 'c', 'x', 'y', 'z'})); } +TEST_CASE("The option terminator works as expected", "[args]") +{ + args::ArgumentParser parser("This is a test program.", "This goes after the options."); + args::Positional<std::string> foo(parser, "FOO", "test flag"); + args::Positional<bool> bar(parser, "BAR", "test flag"); + args::PositionalList<std::string> baz(parser, "BAZ", "test flag"); + args::Flag ofoo(parser, "FOO", "test flag", {'f', "foo"}); + args::Flag obar(parser, "BAR", "test flag", {"bar", 'b'}); + args::ValueFlag<double> obaz(parser, "BAZ", "test flag", {'a', "baz"}); + parser.ParseArgs(std::vector<std::string>{"--foo", "this is a test flag", "0", "a", "b", "--baz", "7.0", "c", "x", "y", "z"}); + REQUIRE(foo); + REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE(bar); + REQUIRE(!args::get(bar)); + REQUIRE(baz); + REQUIRE((args::get(baz) == std::vector<std::string>{"a", "b", "c", "x", "y", "z"})); + REQUIRE(ofoo); + REQUIRE(!obar); + REQUIRE(obaz); + parser.ParseArgs(std::vector<std::string>{"--foo", "this is a test flag", "0", "a", "--", "b", "--baz", "7.0", "c", "x", "y", "z"}); + REQUIRE(foo); + REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE(bar); + REQUIRE(!args::get(bar)); + REQUIRE(baz); + REQUIRE((args::get(baz) == std::vector<std::string>{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); + REQUIRE(ofoo); + REQUIRE(!obar); + REQUIRE(!obaz); + parser.ParseArgs(std::vector<std::string>{"--foo", "--", "this is a test flag", "0", "a", "b", "--baz", "7.0", "c", "x", "y", "z"}); + REQUIRE(foo); + REQUIRE((args::get(foo) == "this is a test flag")); + REQUIRE(bar); + REQUIRE(!args::get(bar)); + REQUIRE(baz); + REQUIRE((args::get(baz) == std::vector<std::string>{"a", "b", "--baz", "7.0", "c", "x", "y", "z"})); + REQUIRE(ofoo); + REQUIRE(!obar); + REQUIRE(!obaz); +} + TEST_CASE("Positional lists work with sets", "[args]") { args::ArgumentParser parser("This is a test program.", "This goes after the options."); |