diff options
author | Jarryd Beck <jarro.2783@gmail.com> | 2017-11-27 00:36:34 +0300 |
---|---|---|
committer | Jarryd Beck <jarro.2783@gmail.com> | 2017-11-27 00:36:34 +0300 |
commit | 0a49b82072f9dbe1d13c5f1b5db54ac07a0e078e (patch) | |
tree | d9cb25edf2a52da97913c2bd64a210fd2a69633b /test | |
parent | 92779bef6650bb84508e95bd417714e716dcdda5 (diff) |
add a test for broken boolean options
The parsing for boolean options was broken by 6c9bae4a07 which added implicit
and default values, and the ability to parse boolean strings. Having an option
after the boolean tried to parse that into the boolean instead of as a
positional parameter.
See #84 for the bug report.
Diffstat (limited to 'test')
-rw-r--r-- | test/options.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/options.cpp b/test/options.cpp index afd7292..387f956 100644 --- a/test/options.cpp +++ b/test/options.cpp @@ -423,9 +423,12 @@ TEST_CASE("Booleans", "[boolean]") { ("bool", "A Boolean", cxxopts::value<bool>()) ("debug", "Debugging", cxxopts::value<bool>()) ("timing", "Timing", cxxopts::value<bool>()) + ("others", "Other arguments", cxxopts::value<std::vector<std::string>>()) ; - Argv av({"booleans", "--bool=false", "--debug", "true", "--timing"}); + options.parse_positional("others"); + + Argv av({"booleans", "--bool=false", "--debug", "true", "--timing", "extra"}); char** argv = av.argv(); auto argc = av.argc(); @@ -439,4 +442,6 @@ TEST_CASE("Booleans", "[boolean]") { CHECK(result["bool"].as<bool>() == false); CHECK(result["debug"].as<bool>() == true); CHECK(result["timing"].as<bool>() == true); + + REQUIRE(result.count("others") == 1); } |