[Lldb-commits] [PATCH] D50334: Add ConstString test FromMidOfBufferStringRef

Phabricator via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 8 14:58:40 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB339292: Add ConstString test FromMidOfBufferStringRef (authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50334?vs=159298&id=159806#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50334

Files:
  unittests/Utility/ConstStringTest.cpp


Index: unittests/Utility/ConstStringTest.cpp
===================================================================
--- unittests/Utility/ConstStringTest.cpp
+++ unittests/Utility/ConstStringTest.cpp
@@ -34,6 +34,26 @@
   EXPECT_EQ("bar", counterpart.GetStringRef());
 }
 
+TEST(ConstStringTest, FromMidOfBufferStringRef) {
+  // StringRef's into bigger buffer: no null termination
+  const char *buffer = "foobarbaz";
+  llvm::StringRef foo_ref(buffer, 3);
+  llvm::StringRef bar_ref(buffer + 3, 3);
+
+  ConstString foo(foo_ref);
+
+  ConstString bar;
+  bar.SetStringWithMangledCounterpart(bar_ref, foo);
+  EXPECT_EQ("bar", bar.GetStringRef());
+
+  ConstString counterpart;
+  EXPECT_TRUE(bar.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("foo", counterpart.GetStringRef());
+
+  EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("bar", counterpart.GetStringRef());
+}
+
 TEST(ConstStringTest, NullAndEmptyStates) {
   ConstString foo("foo");
   EXPECT_FALSE(!foo);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50334.159806.patch
Type: text/x-patch
Size: 988 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180808/bcaf0f19/attachment.bin>


More information about the lldb-commits mailing list