1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 20:23:55 +00:00

resolve ambiguity for vector<array> options (#1147)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top 2025-04-13 07:15:11 -07:00 committed by GitHub
parent 6fbdbaf308
commit a8d6b84cfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -871,6 +871,22 @@ TEST_CASE_METHOD(TApp, "vectorPair", "[optiontype]") {
CHECK_THROWS_AS(run(), CLI::ValidationError); CHECK_THROWS_AS(run(), CLI::ValidationError);
} }
// now with independent type sizes and expected this is possible
TEST_CASE_METHOD(TApp, "vectorArray", "[optiontype]") {
std::vector<std::array<int, 3>> custom_opt;
auto *opt = app.add_option("--set", custom_opt);
args = {"--set", "1", "2", "3", "--set", "3", "4", "5"};
run();
REQUIRE(2u == custom_opt.size());
CHECK(1 == custom_opt[0][0]);
CHECK(4 == custom_opt[1][1]);
CHECK(opt->get_type_size() == 3);
}
TEST_CASE_METHOD(TApp, "vectorPairFail", "[optiontype]") { TEST_CASE_METHOD(TApp, "vectorPairFail", "[optiontype]") {
std::vector<std::pair<int, std::string>> custom_opt; std::vector<std::pair<int, std::string>> custom_opt;