Commit cca5472def3b548ad7de11c6e988ba709062a76c
1 parent
848880d9
failing test
Showing
1 changed file
with
18 additions
and
0 deletions
test/options.cpp
| ... | ... | @@ -175,3 +175,21 @@ TEST_CASE("No positional with extras", "[positional]") |
| 175 | 175 | CHECK(argv[0] == std::string("extras")); |
| 176 | 176 | CHECK(argv[1] == std::string("a")); |
| 177 | 177 | } |
| 178 | + | |
| 179 | +TEST_CASE("Empty with implicit value", "[implicit]") | |
| 180 | +{ | |
| 181 | + cxxopts::Options options("empty_implicit", "doesn't handle empty"); | |
| 182 | + options.add_options() | |
| 183 | + ("implicit", "Has implicit", cxxopts::value<std::string>() | |
| 184 | + ->implicit_value("foo")); | |
| 185 | + | |
| 186 | + Argv av({"implicit", "--implicit", ""}); | |
| 187 | + | |
| 188 | + char** argv = av.argv(); | |
| 189 | + auto argc = av.argc(); | |
| 190 | + | |
| 191 | + options.parse(argc, argv); | |
| 192 | + | |
| 193 | + REQUIRE(options.count("implicit") == 1); | |
| 194 | + REQUIRE(options["implicit"].as<std::string>() == ""); | |
| 195 | +} | ... | ... |