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:
parent
6fbdbaf308
commit
a8d6b84cfc
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user