Skip to content

Commit 246b7c9

Browse files
committed
resolve ambiguity for vector<array> options
1 parent 6fbdbaf commit 246b7c9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/OptionTypeTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,23 @@ TEST_CASE_METHOD(TApp, "vectorPair", "[optiontype]") {
871871
CHECK_THROWS_AS(run(), CLI::ValidationError);
872872
}
873873

874+
// now with independent type sizes and expected this is possible
875+
TEST_CASE_METHOD(TApp, "vectorArray", "[optiontype]") {
876+
877+
std::vector<std::array<int, 3>> custom_opt;
878+
879+
auto *opt = app.add_option("--set", custom_opt);
880+
881+
args = {"--set", "1", "2","3", "--set", "3", "4" , "5"};
882+
883+
run();
884+
REQUIRE(2u == custom_opt.size());
885+
CHECK(1 == custom_opt[0][0]);
886+
CHECK(4 == custom_opt[1][1]);
887+
CHECK(opt->get_type_size()==3);
888+
889+
}
890+
874891
TEST_CASE_METHOD(TApp, "vectorPairFail", "[optiontype]") {
875892

876893
std::vector<std::pair<int, std::string>> custom_opt;

0 commit comments

Comments
 (0)