summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/TinyPtrVectorTest.cpp
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2014-12-31 23:33:24 +0000
committerMichael Gottesman <mgottesman@apple.com>2014-12-31 23:33:24 +0000
commit4c638994ac2708a6131b55be8e855a653d55a4e9 (patch)
tree538d80713160dc4b608271d7369e60f97871bb69 /llvm/unittests/ADT/TinyPtrVectorTest.cpp
parent64670671e64ab16139c7a84fb7d38f46582f8d5f (diff)
downloadbcm5719-llvm-4c638994ac2708a6131b55be8e855a653d55a4e9.tar.gz
bcm5719-llvm-4c638994ac2708a6131b55be8e855a653d55a4e9.zip
Add 2x constructors for TinyPtrVector, one that takes in one elemenet and the other that takes in an ArrayRef<EltTy>
Currently one can only construct an empty TinyPtrVector. These are just missing elements of the API. llvm-svn: 225055
Diffstat (limited to 'llvm/unittests/ADT/TinyPtrVectorTest.cpp')
-rw-r--r--llvm/unittests/ADT/TinyPtrVectorTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/TinyPtrVectorTest.cpp b/llvm/unittests/ADT/TinyPtrVectorTest.cpp
index ec868d4258a..a402e8be9df 100644
--- a/llvm/unittests/ADT/TinyPtrVectorTest.cpp
+++ b/llvm/unittests/ADT/TinyPtrVectorTest.cpp
@@ -412,3 +412,29 @@ TYPED_TEST(TinyPtrVectorTest, InsertRange) {
}
}
+
+TEST(TinyPtrVectorTest, SingleEltCtorTest) {
+ int v = 55;
+ TinyPtrVector<int *> V(&v);
+
+ EXPECT_TRUE(V.size() == 1);
+ EXPECT_FALSE(V.empty());
+ EXPECT_TRUE(V.front() == &v);
+}
+
+TEST(TinyPtrVectorTest, ArrayRefCtorTest) {
+ int data_array[128];
+ std::vector<int *> data;
+
+ for (unsigned i = 0, e = 128; i != e; ++i) {
+ data_array[i] = 324 - int(i);
+ data.push_back(&data_array[i]);
+ }
+
+ TinyPtrVector<int *> V(data);
+ EXPECT_TRUE(V.size() == 128);
+ EXPECT_FALSE(V.empty());
+ for (unsigned i = 0, e = 128; i != e; ++i) {
+ EXPECT_TRUE(V[i] == data[i]);
+ }
+}
OpenPOWER on IntegriCloud