Commit 0ca8a43ebd4ee8c10918c4ea92c297ee715b4d77
1 parent
7b015353
Better ini config behavour with one quote
Showing
3 changed files
with
4 additions
and
9 deletions
include/CLI/StringTools.hpp
| @@ -167,7 +167,7 @@ std::vector<std::string> inline split_up(std::string str) { | @@ -167,7 +167,7 @@ std::vector<std::string> inline split_up(std::string str) { | ||
| 167 | output.push_back(str.substr(1,end-1)); | 167 | output.push_back(str.substr(1,end-1)); |
| 168 | str = str.substr(end+1); | 168 | str = str.substr(end+1); |
| 169 | } else { | 169 | } else { |
| 170 | - output.push_back(str); | 170 | + output.push_back(str.substr(1)); |
| 171 | str = ""; | 171 | str = ""; |
| 172 | } | 172 | } |
| 173 | } else if(str[0] == '\"') { | 173 | } else if(str[0] == '\"') { |
| @@ -176,7 +176,7 @@ std::vector<std::string> inline split_up(std::string str) { | @@ -176,7 +176,7 @@ std::vector<std::string> inline split_up(std::string str) { | ||
| 176 | output.push_back(str.substr(1,end-1)); | 176 | output.push_back(str.substr(1,end-1)); |
| 177 | str = str.substr(end+1); | 177 | str = str.substr(end+1); |
| 178 | } else { | 178 | } else { |
| 179 | - output.push_back(str); | 179 | + output.push_back(str.substr(1)); |
| 180 | str = ""; | 180 | str = ""; |
| 181 | } | 181 | } |
| 182 | 182 |
tests/HelpersTest.cpp
| @@ -298,12 +298,12 @@ TEST(SplitUp, Spaces) { | @@ -298,12 +298,12 @@ TEST(SplitUp, Spaces) { | ||
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | TEST(SplitUp, BadStrings) { | 300 | TEST(SplitUp, BadStrings) { |
| 301 | - std::vector<std::string> oput = {"one", "\" two three"}; | 301 | + std::vector<std::string> oput = {"one", " two three"}; |
| 302 | std::string orig {" one \" two three "}; | 302 | std::string orig {" one \" two three "}; |
| 303 | std::vector<std::string> result = CLI::detail::split_up(orig); | 303 | std::vector<std::string> result = CLI::detail::split_up(orig); |
| 304 | EXPECT_EQ(oput, result); | 304 | EXPECT_EQ(oput, result); |
| 305 | 305 | ||
| 306 | - oput = {"one", "\' two three"}; | 306 | + oput = {"one", " two three"}; |
| 307 | orig = " one \' two three "; | 307 | orig = " one \' two three "; |
| 308 | result = CLI::detail::split_up(orig); | 308 | result = CLI::detail::split_up(orig); |
| 309 | EXPECT_EQ(oput, result); | 309 | EXPECT_EQ(oput, result); |
tests/IniTest.cpp