MCPcopy Create free account
hub / github.com/chen3feng/toft / TestSplitLines

Function TestSplitLines

base/string/algorithm_test.cpp:199–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198template <typename StringType>
199static void TestSplitLines() {
200 vector<StringType> lines;
201 StringType str = "abc\r\n" "\n" "bc";
202 SplitLines(str, &lines);
203 EXPECT_EQ(3U, lines.size());
204 EXPECT_EQ("abc", lines[0]);
205 EXPECT_EQ("", lines[1]);
206 EXPECT_EQ("bc", lines[2]);
207
208 lines.clear();
209 SplitLines(str, &lines, true);
210 EXPECT_EQ(3U, lines.size());
211 EXPECT_EQ("abc\r\n", lines[0]);
212 EXPECT_EQ("\n", lines[1]);
213 EXPECT_EQ("bc", lines[2]);
214
215 str = "abc\r\n" "\r\n" "bc\r\n" "aaa\n" "\n" "\r\n";
216 SplitLines(str, &lines);
217 EXPECT_EQ(6U, lines.size());
218 EXPECT_EQ("abc", lines[0]);
219 EXPECT_EQ("", lines[1]);
220 EXPECT_EQ("bc", lines[2]);
221 EXPECT_EQ("aaa", lines[3]);
222 EXPECT_EQ("", lines[4]);
223 EXPECT_EQ("", lines[5]);
224}
225
226TEST(String, SplitLines)
227{

Callers

nothing calls this directly

Calls 3

SplitLinesFunction · 0.85
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected