Changes default values so that they aren't counted
Fixes #96. Default values of options not specified on the command line had a `count` of 1. It would be better if they had a count of 0 because they were not actually specified, so that count is only for options given by the user.
This commit is contained in:
parent
76717cb3dd
commit
e792760ab9
@ -1003,7 +1003,6 @@ namespace cxxopts
|
||||
{
|
||||
ensure_value(details);
|
||||
m_value->parse();
|
||||
m_count++;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
@ -243,7 +243,7 @@ TEST_CASE("Default values", "[default]")
|
||||
auto argc = av.argc();
|
||||
|
||||
auto result = options.parse(argc, argv);
|
||||
CHECK(result.count("default") == 1);
|
||||
CHECK(result.count("default") == 0);
|
||||
CHECK(result["default"].as<int>() == 42);
|
||||
}
|
||||
|
||||
@ -441,9 +441,9 @@ TEST_CASE("Booleans", "[boolean]") {
|
||||
REQUIRE(result.count("bool") == 1);
|
||||
REQUIRE(result.count("debug") == 1);
|
||||
REQUIRE(result.count("timing") == 1);
|
||||
REQUIRE(result.count("noExplicitDefault") == 1);
|
||||
REQUIRE(result.count("defaultTrue") == 1);
|
||||
REQUIRE(result.count("defaultFalse") == 1);
|
||||
REQUIRE(result.count("noExplicitDefault") == 0);
|
||||
REQUIRE(result.count("defaultTrue") == 0);
|
||||
REQUIRE(result.count("defaultFalse") == 0);
|
||||
|
||||
CHECK(result["bool"].as<bool>() == false);
|
||||
CHECK(result["debug"].as<bool>() == true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user