summaryrefslogtreecommitdiff
path: root/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ADT/StringRefTest.cpp')
-rw-r--r--unittests/ADT/StringRefTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index 8a2c7435d8..bb46dc010a 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/unittests/ADT/StringRefTest.cpp
@@ -56,4 +56,16 @@ TEST(StringRefTest, Operators) {
EXPECT_EQ('a', StringRef("aab")[1]);
}
+TEST(StringRefTest, Utilities) {
+ StringRef Str("hello");
+ EXPECT_TRUE(Str.substr(3) == "lo");
+ EXPECT_TRUE(Str.substr(100) == "");
+ EXPECT_TRUE(Str.substr(0, 100) == "hello");
+ EXPECT_TRUE(Str.substr(4, 10) == "o");
+
+ EXPECT_TRUE(Str.startswith("he"));
+ EXPECT_FALSE(Str.startswith("helloworld"));
+ EXPECT_FALSE(Str.startswith("hi"));
+}
+
} // end anonymous namespace