Skip to content

Commit

Permalink
more clean up of bracket processing
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Jan 2, 2025
1 parent 7250801 commit 39fa3f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 0 additions & 4 deletions include/CLI/impl/Option_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,10 +693,6 @@ CLI11_INLINE int Option::_add_result(std::string &&result, std::vector<std::stri
result.erase(result.begin());
bool skipSection{false};
for(auto &var : CLI::detail::split_up(result, ',')) {
if(var == result) {
skipSection = true;
break;
}
if(!var.empty()) {
result_count += _add_result(std::move(var), res);
}
Expand Down
24 changes: 18 additions & 6 deletions tests/OptionTypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,17 +1227,17 @@ TEST_CASE_METHOD(TApp, "vectorSingleArg", "[optiontype]") {

TEST_CASE_METHOD(TApp, "vectorEmptyArg", "[optiontype]") {

std::vector<std::string> cv{"test"};
std::vector<std::string> cv{ "test" };
app.add_option("-c", cv);
args = {"-c", "test1", "[]"};
args = { "-c","test1", "[]"};

run();
CHECK(cv.size() == 1);
args = {"-c", "test1", "[[]]"};
CHECK(cv.size()==1);
args = { "-c","test1", "[[]]"};

run();
CHECK(cv.size() == 2);
CHECK(cv[1] == "[]");
CHECK(cv.size()==2);
CHECK(cv[1]=="[]");
}

TEST_CASE_METHOD(TApp, "vectorDoubleArg", "[optiontype]") {
Expand All @@ -1264,6 +1264,18 @@ TEST_CASE_METHOD(TApp, "vectorEmpty", "[optiontype]") {
CHECK(cv.empty());
}

TEST_CASE_METHOD(TApp, "vectorVectorArg", "[optiontype]") {

std::vector<std::vector<std::string>> cv{};
app.add_option("-c", cv);
args = { "-c","[[a,b]]"};

run();
CHECK(cv.size()==1);
CHECK(cv[0].size() == 2);
CHECK(cv[0][0]=="a");
}

TEST_CASE_METHOD(TApp, "OnParseCall", "[optiontype]") {

int cnt{0};
Expand Down

0 comments on commit 39fa3f4

Please sign in to comment.