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.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index 6cf2e6a0454dc..66e5944b56eb7 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/unittests/ADT/StringRefTest.cpp
@@ -301,7 +301,7 @@ TEST(StringRefTest, Trim) {
EXPECT_EQ(StringRef(""), StringRef(" ").trim());
EXPECT_EQ(StringRef("\0", 1), StringRef(" \0 ", 3).trim());
EXPECT_EQ(StringRef("\0\0", 2), StringRef("\0\0", 2).trim());
- EXPECT_EQ(StringRef("x"), StringRef("\0\0x\0\0", 5).trim(StringRef("\0", 1)));
+ EXPECT_EQ(StringRef("x"), StringRef("\0\0x\0\0", 5).trim('\0'));
}
TEST(StringRefTest, StartsWith) {
@@ -589,6 +589,15 @@ TEST(StringRefTest, joinStrings) {
TEST(StringRefTest, AllocatorCopy) {
BumpPtrAllocator Alloc;
+ // First test empty strings. We don't want these to allocate anything on the
+ // allocator.
+ StringRef StrEmpty = "";
+ StringRef StrEmptyc = StrEmpty.copy(Alloc);
+ EXPECT_TRUE(StrEmpty.equals(StrEmptyc));
+ EXPECT_EQ(StrEmptyc.data(), nullptr);
+ EXPECT_EQ(StrEmptyc.size(), 0u);
+ EXPECT_EQ(Alloc.getTotalMemory(), 0u);
+
StringRef Str1 = "hello";
StringRef Str2 = "bye";
StringRef Str1c = Str1.copy(Alloc);