aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-04-27 00:37:06 -0700
committerGitHub <noreply@github.com>2024-04-27 00:37:06 -0700
commit9bb84cec1b5375c24e5fa9cf7700070d9d1b4184 (patch)
tree6f0b933b5fc66b69f4f6f3ee6dd60789472db082 /llvm/unittests/ADT/StringRefTest.cpp
parent7aa6896dd7bcdcb1d09f4f98e356c43d723d9d6b (diff)
downloadllvm-9bb84cec1b5375c24e5fa9cf7700070d9d1b4184.zip
llvm-9bb84cec1b5375c24e5fa9cf7700070d9d1b4184.tar.gz
llvm-9bb84cec1b5375c24e5fa9cf7700070d9d1b4184.tar.bz2
[ADT] Add StringRef::{starts,ends}_with(char) (#90311)
This patch adds to StringRef the equivalent of std::string_view::{starts,ends}_with(char) in C++20.
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index 8df71e8..fa537e8 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -368,6 +368,8 @@ TEST(StringRefTest, StartsWith) {
EXPECT_TRUE(Str.starts_with("he"));
EXPECT_FALSE(Str.starts_with("helloworld"));
EXPECT_FALSE(Str.starts_with("hi"));
+ EXPECT_TRUE(Str.starts_with('h'));
+ EXPECT_FALSE(Str.starts_with('i'));
}
TEST(StringRefTest, StartsWithInsensitive) {
@@ -421,6 +423,8 @@ TEST(StringRefTest, EndsWith) {
EXPECT_FALSE(Str.ends_with("helloworld"));
EXPECT_FALSE(Str.ends_with("worldhello"));
EXPECT_FALSE(Str.ends_with("so"));
+ EXPECT_TRUE(Str.ends_with('o'));
+ EXPECT_FALSE(Str.ends_with('p'));
}
TEST(StringRefTest, EndsWithInsensitive) {