Commit db674a467ff34b839078ca307b34f73596197001
1 parent
c45bcc38
test for hiding options
Showing
1 changed file
with
27 additions
and
0 deletions
test/options.cpp
| ... | ... | @@ -91,6 +91,33 @@ TEST_CASE("No positional", "[positional]") |
| 91 | 91 | CHECK(strcmp(argv[1], "a") == 0); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | +TEST_CASE("All positional", "[positional]") | |
| 95 | +{ | |
| 96 | + std::vector<std::string> positional; | |
| 97 | + | |
| 98 | + cxxopts::Options options("test_all_positional", " - test all positional"); | |
| 99 | + options.add_options() | |
| 100 | + ("positional", "Positional parameters", | |
| 101 | + cxxopts::value<std::vector<std::string>>(positional)) | |
| 102 | + ; | |
| 103 | + | |
| 104 | + Argv av({"tester", "a", "b", "c"}); | |
| 105 | + | |
| 106 | + auto argc = av.argc(); | |
| 107 | + auto argv = av.argv(); | |
| 108 | + | |
| 109 | + options.parse_positional("positional"); | |
| 110 | + | |
| 111 | + options.parse(argc, argv); | |
| 112 | + | |
| 113 | + REQUIRE(argc == 1); | |
| 114 | + REQUIRE(positional.size() == 3); | |
| 115 | + | |
| 116 | + CHECK(positional[0] == "a"); | |
| 117 | + CHECK(positional[1] == "b"); | |
| 118 | + CHECK(positional[2] == "c"); | |
| 119 | +} | |
| 120 | + | |
| 94 | 121 | TEST_CASE("Some positional explicit", "[positional]") |
| 95 | 122 | { |
| 96 | 123 | cxxopts::Options options("positional_explicit", " - test positional"); | ... | ... |