diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-14 15:36:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-14 15:36:25 +0200 |
commit | b237ba57ea4ed9d6f1c450240a5e068f867bbd43 (patch) | |
tree | c76ea6ec0d3f8dd8b4cfafc783c45fb25e5170e6 /AK | |
parent | 236dcf770289200d404caa819a9aea3a0aaae44d (diff) | |
download | serenity-b237ba57ea4ed9d6f1c450240a5e068f867bbd43.zip |
AK: Add a little test for String::split()
Just to verify that the parts are all null-terminated.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Tests/TestString.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/AK/Tests/TestString.cpp b/AK/Tests/TestString.cpp index eb82d4ccd6..fab4f1cc57 100644 --- a/AK/Tests/TestString.cpp +++ b/AK/Tests/TestString.cpp @@ -184,4 +184,18 @@ TEST_CASE(replace) EXPECT(test_string == "111._.|||._.|||"); } +TEST_CASE(split) +{ + String test = "foo bar baz"; + auto parts = test.split(' '); + EXPECT_EQ(parts.size(), 3u); + EXPECT_EQ(parts[0], "foo"); + EXPECT_EQ(parts[1], "bar"); + EXPECT_EQ(parts[2], "baz"); + + EXPECT_EQ(parts[0].characters()[3], '\0'); + EXPECT_EQ(parts[1].characters()[3], '\0'); + EXPECT_EQ(parts[2].characters()[3], '\0'); +} + TEST_MAIN(String) |