mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 13:13:53 +00:00
fix: a failing test case for toml string_vector processing (#491)
This commit is contained in:
parent
34bd80971b
commit
102e201dc7
@ -310,7 +310,12 @@ inline std::vector<std::string> split_up(std::string str, char delimiter = '\0')
|
||||
}
|
||||
if(end != std::string::npos) {
|
||||
output.push_back(str.substr(1, end - 1));
|
||||
str = str.substr(end + 1);
|
||||
if(end + 2 < str.size()) {
|
||||
str = str.substr(end + 2);
|
||||
} else {
|
||||
str.clear();
|
||||
}
|
||||
|
||||
} else {
|
||||
output.push_back(str.substr(1));
|
||||
str = "";
|
||||
|
@ -770,6 +770,30 @@ TEST_F(TApp, TOMLVectordirect) {
|
||||
EXPECT_EQ(std::vector<int>({1, 2, 3}), three);
|
||||
}
|
||||
|
||||
TEST_F(TApp, TOMLStringVector) {
|
||||
|
||||
TempFile tmptoml{"TestTomlTmp.toml"};
|
||||
|
||||
app.set_config("--config", tmptoml);
|
||||
|
||||
{
|
||||
std::ofstream out{tmptoml};
|
||||
out << "#this is a comment line\n";
|
||||
out << "[default]\n";
|
||||
out << "two=[\"2\",\"3\"]\n";
|
||||
out << "three=[\"1\",\"2\",\"3\"]\n";
|
||||
}
|
||||
|
||||
std::vector<std::string> two, three;
|
||||
app.add_option("--two", two)->required();
|
||||
app.add_option("--three", three)->required();
|
||||
|
||||
run();
|
||||
|
||||
EXPECT_EQ(std::vector<std::string>({"2", "3"}), two);
|
||||
EXPECT_EQ(std::vector<std::string>({"1", "2", "3"}), three);
|
||||
}
|
||||
|
||||
TEST_F(TApp, IniVectorCsep) {
|
||||
|
||||
TempFile tmpini{"TestIniTmp.ini"};
|
||||
|
Loading…
x
Reference in New Issue
Block a user