summaryrefslogtreecommitdiff
path: root/AK/Tests/TestStringView.cpp
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2020-02-15 10:14:22 +1300
committerAndreas Kling <kling@serenityos.org>2020-02-22 21:36:54 +0100
commit854f0b9e1aa2504c89165f551cb6c56e59b4d9e8 (patch)
tree0b4641e4dc306e8f9d005ec9ff3c0333cf0e472e /AK/Tests/TestStringView.cpp
parenta406a8c7d29904140e183b2afe25342acdeeebad (diff)
downloadserenity-854f0b9e1aa2504c89165f551cb6c56e59b4d9e8.zip
AK: Add StringView::starts_with(char) & StringView::ends_with(char)
This is simply meant to be a more efficient implementation in the case that we only need to check a single character.
Diffstat (limited to 'AK/Tests/TestStringView.cpp')
-rw-r--r--AK/Tests/TestStringView.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/AK/Tests/TestStringView.cpp b/AK/Tests/TestStringView.cpp
index 8b3fb3841e..a9e032470e 100644
--- a/AK/Tests/TestStringView.cpp
+++ b/AK/Tests/TestStringView.cpp
@@ -63,6 +63,8 @@ TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
StringView test_string_view = test_string.view();
+ EXPECT(test_string_view.starts_with('A'));
+ EXPECT(!test_string_view.starts_with('B'));
EXPECT(test_string_view.starts_with("AB"));
EXPECT(test_string_view.starts_with("ABCDEF"));
EXPECT(!test_string_view.starts_with("DEF"));
@@ -73,6 +75,8 @@ TEST_CASE(ends_with)
String test_string = "ABCDEF";
StringView test_string_view = test_string.view();
EXPECT(test_string_view.ends_with("DEF"));
+ EXPECT(test_string_view.ends_with('F'));
+ EXPECT(!test_string_view.ends_with('E'));
EXPECT(test_string_view.ends_with("ABCDEF"));
EXPECT(!test_string_view.ends_with("ABCDE"));
EXPECT(!test_string_view.ends_with("ABCDEFG"));