summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-12-21 06:49:24 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-12-21 06:49:24 +0000
commit00879d8faaaad96bee7c0bdc889d6f85270c18c4 (patch)
tree75c175cad6eb1fa9c5de739e071cd730ca31e9df /llvm/unittests
parent7bc85a931ecb6843ad3289ef708d85a8b15f2e6d (diff)
downloadbcm5719-llvm-00879d8faaaad96bee7c0bdc889d6f85270c18c4.tar.gz
bcm5719-llvm-00879d8faaaad96bee7c0bdc889d6f85270c18c4.zip
Change StringRef::startswith and StringRef::endswith to versions which are a
bit more verbose, but optimize to much shorter code. llvm-svn: 91817
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index dfa208abefd..19665df88d5 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -198,6 +198,14 @@ TEST(StringRefTest, StartsWith) {
EXPECT_FALSE(Str.startswith("hi"));
}
+TEST(StringRefTest, EndsWith) {
+ StringRef Str("hello");
+ EXPECT_TRUE(Str.endswith("lo"));
+ EXPECT_FALSE(Str.endswith("helloworld"));
+ EXPECT_FALSE(Str.endswith("worldhello"));
+ EXPECT_FALSE(Str.endswith("so"));
+}
+
TEST(StringRefTest, Find) {
StringRef Str("hello");
EXPECT_EQ(2U, Str.find('l'));
OpenPOWER on IntegriCloud