diff options
author | Stephen Hines <srhines@google.com> | 2015-04-01 18:49:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-01 18:49:26 +0000 |
commit | 3fa16bd6062e23bcdb82ed4dd965674792e6b761 (patch) | |
tree | 9348fc507292f7e8715d22d64ce5a32131b4f875 /unittests/ADT/TinyPtrVectorTest.cpp | |
parent | beed47390a60f6f0c77532b3d3f76bb47ef49423 (diff) | |
parent | ebe69fe11e48d322045d5949c83283927a0d790b (diff) | |
download | external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.zip external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.gz external_llvm-3fa16bd6062e23bcdb82ed4dd965674792e6b761.tar.bz2 |
Merge "Update aosp/master LLVM for rebase to r230699."
Diffstat (limited to 'unittests/ADT/TinyPtrVectorTest.cpp')
-rw-r--r-- | unittests/ADT/TinyPtrVectorTest.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/unittests/ADT/TinyPtrVectorTest.cpp b/unittests/ADT/TinyPtrVectorTest.cpp index ec868d4..294dfac 100644 --- a/unittests/ADT/TinyPtrVectorTest.cpp +++ b/unittests/ADT/TinyPtrVectorTest.cpp @@ -412,3 +412,50 @@ 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]); + } +} + +TEST(TinyPtrVectorTest, MutableArrayRefTest) { + 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()); + + MutableArrayRef<int *> mut_array = V; + for (unsigned i = 0, e = 128; i != e; ++i) { + EXPECT_TRUE(mut_array[i] == data[i]); + mut_array[i] = 324 + mut_array[i]; + EXPECT_TRUE(mut_array[i] == (324 + data[i])); + } +} |