1 //===- llvm/unittest/ADT/ArrayRefTest.cpp - ArrayRef unit tests -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/ArrayRef.h"
11 #include "llvm/Support/Allocator.h"
12 #include "llvm/Support/raw_ostream.h"
13 #include "gtest/gtest.h"
18 TEST(ArrayRefTest, AllocatorCopy) {
19 BumpPtrAllocator Alloc;
20 static const uint16_t Words1[] = { 1, 4, 200, 37 };
21 ArrayRef<uint16_t> Array1 = makeArrayRef(Words1, 4);
22 static const uint16_t Words2[] = { 11, 4003, 67, 64000, 13 };
23 ArrayRef<uint16_t> Array2 = makeArrayRef(Words2, 5);
24 ArrayRef<uint16_t> Array1c = Array1.copy(Alloc);
25 ArrayRef<uint16_t> Array2c = Array2.copy(Alloc);;
26 EXPECT_TRUE(Array1.equals(Array1c));
27 EXPECT_NE(Array1.data(), Array1c.data());
28 EXPECT_TRUE(Array2.equals(Array2c));
29 EXPECT_NE(Array2.data(), Array2c.data());
33 } // end anonymous namespace