From 0a49b82072f9dbe1d13c5f1b5db54ac07a0e078e Mon Sep 17 00:00:00 2001 From: Jarryd Beck Date: Mon, 27 Nov 2017 08:36:34 +1100 Subject: [PATCH] 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. --- test/options.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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()) ("debug", "Debugging", cxxopts::value()) ("timing", "Timing", cxxopts::value()) + ("others", "Other arguments", cxxopts::value>()) ; - 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() == false); CHECK(result["debug"].as() == true); CHECK(result["timing"].as() == true); + + REQUIRE(result.count("others") == 1); }