diff options
author | Nick Kledzik <kledzik@apple.com> | 2014-02-05 22:22:56 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2014-02-05 22:22:56 +0000 |
commit | 4d6d981297d265341eef6ef6ff89dabfe8ca4a78 (patch) | |
tree | bafe74bd82dae7d91318f2cc62528022c2a8e21f /llvm/unittests/ADT/StringRefTest.cpp | |
parent | 2cb4a78f9394359e3bb74060774e2245bcb9f4b7 (diff) | |
download | llvm-4d6d981297d265341eef6ef6ff89dabfe8ca4a78.zip llvm-4d6d981297d265341eef6ef6ff89dabfe8ca4a78.tar.gz llvm-4d6d981297d265341eef6ef6ff89dabfe8ca4a78.tar.bz2 |
Fix layering StringRef copy using BumpPtrAllocator.
Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy:
StringRef myCopy = myStr.copy(myAllocator);
llvm-svn: 200885
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/StringRefTest.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index 0ab8fcf..c7fd9d0 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" using namespace llvm; @@ -531,4 +532,18 @@ TEST(StringRefTest, joinStrings) { EXPECT_TRUE(v2_join3); } + +TEST(StringRefTest, AllocatorCopy) { + BumpPtrAllocator Alloc; + StringRef Str1 = "hello"; + StringRef Str2 = "bye"; + StringRef Str1c = Str1.copy(Alloc); + StringRef Str2c = Str2.copy(Alloc); + EXPECT_TRUE(Str1.equals(Str1c)); + EXPECT_NE(Str1.data(), Str1c.data()); + EXPECT_TRUE(Str2.equals(Str2c)); + EXPECT_NE(Str2.data(), Str2c.data()); +} + + } // end anonymous namespace |