Skip to content

Commit 70e968c

Browse files
Norman HeinoNorman Heino
authored andcommitted
Fix argument order in StrSplit
1 parent 09a87e3 commit 70e968c

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/string_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ std::vector<std::string> StrSplit(const std::string& str, char delim) {
169169
size_t first = 0;
170170
size_t next = str.find(delim);
171171
for (; next != std::string::npos;
172-
first = next + 1, next = str.find(first, delim)) {
172+
first = next + 1, next = str.find(delim, first)) {
173173
ret.push_back(str.substr(first, next - first));
174174
}
175175
ret.push_back(str.substr(first));

test/string_util_gtest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ TEST(StringUtilTest, StrSplit) {
154154
EXPECT_EQ(benchmark::StrSplit("", ','), std::vector<std::string>{});
155155
EXPECT_EQ(benchmark::StrSplit("hello", ','),
156156
std::vector<std::string>({"hello"}));
157-
EXPECT_EQ(benchmark::StrSplit("hello,there", ','),
158-
std::vector<std::string>({"hello", "there"}));
157+
EXPECT_EQ(benchmark::StrSplit("hello,there,is,more", ','),
158+
std::vector<std::string>({"hello", "there", "is", "more"}));
159159
}
160160

161161
} // end namespace

0 commit comments

Comments
 (0)