mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 05:57:41 +00:00
AK: StringView::lines() should keep empty lines
This commit is contained in:
parent
d422c46ebb
commit
8f80879676
2 changed files with 9 additions and 2 deletions
|
@ -68,7 +68,6 @@ Vector<StringView> StringView::lines(bool consider_cr) const
|
|||
}
|
||||
if (split_view) {
|
||||
ssize_t sublen = i - substart;
|
||||
if (sublen != 0)
|
||||
v.append(substring_view(substart, sublen));
|
||||
substart = i + 1;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,14 @@ TEST_CASE(lines)
|
|||
EXPECT(test_string_vector.at(1) == String("Hello there"));
|
||||
EXPECT(test_string_vector.at(2) == String("Hello there"));
|
||||
EXPECT(test_string_vector.at(3) == String("```"));
|
||||
|
||||
test_string = "\n\n\n";
|
||||
test_string_view = test_string.view();
|
||||
test_string_vector = test_string_view.lines();
|
||||
EXPECT_EQ(test_string_vector.size(), 3);
|
||||
EXPECT_EQ(test_string_vector.at(0).is_empty(), true);
|
||||
EXPECT_EQ(test_string_vector.at(1).is_empty(), true);
|
||||
EXPECT_EQ(test_string_vector.at(2).is_empty(), true);
|
||||
}
|
||||
|
||||
TEST_MAIN(StringView)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue