aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/ArrayRefTest.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-02-05 22:22:56 +0000
committerNick Kledzik <kledzik@apple.com>2014-02-05 22:22:56 +0000
commit4d6d981297d265341eef6ef6ff89dabfe8ca4a78 (patch)
treebafe74bd82dae7d91318f2cc62528022c2a8e21f /llvm/unittests/ADT/ArrayRefTest.cpp
parent2cb4a78f9394359e3bb74060774e2245bcb9f4b7 (diff)
downloadllvm-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/ArrayRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/ArrayRefTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp
new file mode 100644
index 0000000..7133ca7
--- /dev/null
+++ b/llvm/unittests/ADT/ArrayRefTest.cpp
@@ -0,0 +1,33 @@
+//===- llvm/unittest/ADT/ArrayRefTest.cpp - ArrayRef unit tests -----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+using namespace llvm;
+
+namespace llvm {
+
+TEST(ArrayRefTest, AllocatorCopy) {
+ BumpPtrAllocator Alloc;
+ static const uint16_t Words1[] = { 1, 4, 200, 37 };
+ ArrayRef<uint16_t> Array1 = makeArrayRef(Words1, 4);
+ static const uint16_t Words2[] = { 11, 4003, 67, 64000, 13 };
+ ArrayRef<uint16_t> Array2 = makeArrayRef(Words2, 5);
+ ArrayRef<uint16_t> Array1c = Array1.copy(Alloc);
+ ArrayRef<uint16_t> Array2c = Array2.copy(Alloc);;
+ EXPECT_TRUE(Array1.equals(Array1c));
+ EXPECT_NE(Array1.data(), Array1c.data());
+ EXPECT_TRUE(Array2.equals(Array2c));
+ EXPECT_NE(Array2.data(), Array2c.data());
+}
+
+
+} // end anonymous namespace