summaryrefslogtreecommitdiff
path: root/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
commitd5b1f8a8426e82990dafc6e3336fefc6635c8fa4 (patch)
treef36a127f324b061469393df77fddb0f8bcd59258 /unittests
parent65f067fa638ce34329c96b8be133092e9be4ea83 (diff)
downloadllvm-d5b1f8a8426e82990dafc6e3336fefc6635c8fa4.tar.gz
llvm-d5b1f8a8426e82990dafc6e3336fefc6635c8fa4.tar.bz2
llvm-d5b1f8a8426e82990dafc6e3336fefc6635c8fa4.tar.xz
Change StringRef::startswith and StringRef::endswith to versions which are a
bit more verbose, but optimize to much shorter code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/StringRefTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index dfa208abef..19665df88d 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/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'));