X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FADT%2FTinyPtrVectorTest.cpp;h=a4f92ffbe38372f815be2b800ba418a007ca2516;hb=4ff87aaf84f0fbc9dffa2757fd7a33c7ee9044ea;hp=94939279c14771f6bfdfff69dd97517797ca35a7;hpb=06bd8ca8c276d9bc20b192188224e1e5215666a0;p=oota-llvm.git diff --git a/unittests/ADT/TinyPtrVectorTest.cpp b/unittests/ADT/TinyPtrVectorTest.cpp index 94939279c14..a4f92ffbe38 100644 --- a/unittests/ADT/TinyPtrVectorTest.cpp +++ b/unittests/ADT/TinyPtrVectorTest.cpp @@ -11,12 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "gtest/gtest.h" +#include "llvm/ADT/TinyPtrVector.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/TinyPtrVector.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/type_traits.h" +#include "gtest/gtest.h" #include #include #include @@ -157,7 +157,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveCtorTest) { this->expectValues(Copy2, this->testArray(42)); this->expectValues(this->V2, this->testArray(0)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES TypeParam Move(std::move(Copy2)); this->expectValues(Move, this->testArray(42)); this->expectValues(Copy2, this->testArray(0)); @@ -168,7 +168,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(0)); this->expectValues(this->V2, this->testArray(0)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(0)); #endif @@ -177,7 +177,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(0)); this->expectValues(this->V2, this->testArray(0)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(1), this->testArray(0)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(0)); @@ -187,7 +187,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(0)); this->expectValues(this->V2, this->testArray(0)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(2), this->testArray(0)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(0)); @@ -197,7 +197,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(0)); this->expectValues(this->V2, this->testArray(0)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(42), this->testArray(0)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(0)); @@ -207,7 +207,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(1)); this->expectValues(this->V2, this->testArray(1)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(0), this->testArray(1)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(1)); @@ -217,7 +217,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(2)); this->expectValues(this->V2, this->testArray(2)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(0), this->testArray(2)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(2)); @@ -227,7 +227,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(42)); this->expectValues(this->V2, this->testArray(42)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(0), this->testArray(42)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(42)); @@ -237,7 +237,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(1)); this->expectValues(this->V2, this->testArray(1)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(1)); #endif @@ -246,7 +246,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(2)); this->expectValues(this->V2, this->testArray(2)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(1), this->testArray(2)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(2)); @@ -256,7 +256,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(42)); this->expectValues(this->V2, this->testArray(42)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(1), this->testArray(42)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(42)); @@ -266,7 +266,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(1)); this->expectValues(this->V2, this->testArray(1)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(2), this->testArray(1)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(1)); @@ -276,7 +276,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(2)); this->expectValues(this->V2, this->testArray(2)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(2), this->testArray(2)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(2)); @@ -286,7 +286,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(42)); this->expectValues(this->V2, this->testArray(42)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(2), this->testArray(42)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(42)); @@ -296,7 +296,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(1)); this->expectValues(this->V2, this->testArray(1)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(42), this->testArray(1)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(1)); @@ -306,7 +306,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(2)); this->expectValues(this->V2, this->testArray(2)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(42), this->testArray(2)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(2)); @@ -316,7 +316,7 @@ TYPED_TEST(TinyPtrVectorTest, CopyAndMoveTest) { this->V = this->V2; this->expectValues(this->V, this->testArray(42)); this->expectValues(this->V2, this->testArray(42)); -#if LLVM_USE_RVALUE_REFERENCES +#if LLVM_HAS_RVALUE_REFERENCES this->setVectors(this->testArray(42), this->testArray(42)); this->V = std::move(this->V2); this->expectValues(this->V, this->testArray(42)); @@ -354,4 +354,95 @@ TYPED_TEST(TinyPtrVectorTest, EraseTest) { this->expectValues(this->V, this->testArray(0)); } +TYPED_TEST(TinyPtrVectorTest, EraseRangeTest) { + this->appendValues(this->V, this->testArray(1)); + this->expectValues(this->V, this->testArray(1)); + this->V.erase(this->V.begin(), this->V.begin()); + this->expectValues(this->V, this->testArray(1)); + this->V.erase(this->V.end(), this->V.end()); + this->expectValues(this->V, this->testArray(1)); + this->V.erase(this->V.begin(), this->V.end()); + this->expectValues(this->V, this->testArray(0)); + + this->appendValues(this->V, this->testArray(42)); + this->expectValues(this->V, this->testArray(42)); + this->V.erase(this->V.begin(), llvm::next(this->V.begin(), 1)); + this->TestPtrs.erase(this->TestPtrs.begin(), + llvm::next(this->TestPtrs.begin(), 1)); + this->expectValues(this->V, this->testArray(41)); + this->V.erase(llvm::next(this->V.begin(), 1), llvm::next(this->V.begin(), 2)); + this->TestPtrs.erase(llvm::next(this->TestPtrs.begin(), 1), + llvm::next(this->TestPtrs.begin(), 2)); + this->expectValues(this->V, this->testArray(40)); + this->V.erase(llvm::next(this->V.begin(), 2), llvm::next(this->V.begin(), 4)); + this->TestPtrs.erase(llvm::next(this->TestPtrs.begin(), 2), + llvm::next(this->TestPtrs.begin(), 4)); + this->expectValues(this->V, this->testArray(38)); + this->V.erase(llvm::next(this->V.begin(), 5), llvm::next(this->V.begin(), 10)); + this->TestPtrs.erase(llvm::next(this->TestPtrs.begin(), 5), + llvm::next(this->TestPtrs.begin(), 10)); + this->expectValues(this->V, this->testArray(33)); + this->V.erase(llvm::next(this->V.begin(), 13), llvm::next(this->V.begin(), 26)); + this->TestPtrs.erase(llvm::next(this->TestPtrs.begin(), 13), + llvm::next(this->TestPtrs.begin(), 26)); + this->expectValues(this->V, this->testArray(20)); + this->V.erase(llvm::next(this->V.begin(), 7), this->V.end()); + this->expectValues(this->V, this->testArray(7)); + this->V.erase(this->V.begin(), this->V.end()); + this->expectValues(this->V, this->testArray(0)); +} + +TYPED_TEST(TinyPtrVectorTest, Insert) { + this->V.insert(this->V.end(), this->TestPtrs[0]); + this->expectValues(this->V, this->testArray(1)); + this->V.clear(); + this->appendValues(this->V, this->testArray(4)); + this->expectValues(this->V, this->testArray(4)); + this->V.insert(this->V.end(), this->TestPtrs[4]); + this->expectValues(this->V, this->testArray(5)); + this->V.insert(this->V.begin(), this->TestPtrs[42]); + this->TestPtrs.insert(this->TestPtrs.begin(), this->TestPtrs[42]); + this->expectValues(this->V, this->testArray(6)); + this->V.insert(llvm::next(this->V.begin(), 3), this->TestPtrs[43]); + this->TestPtrs.insert(llvm::next(this->TestPtrs.begin(), 3), + this->TestPtrs[43]); + this->expectValues(this->V, this->testArray(7)); +} + +TYPED_TEST(TinyPtrVectorTest, InsertRange) { + this->V.insert(this->V.end(), this->TestPtrs.begin(), this->TestPtrs.begin()); + this->expectValues(this->V, this->testArray(0)); + this->V.insert(this->V.begin(), this->TestPtrs.begin(), + this->TestPtrs.begin()); + this->expectValues(this->V, this->testArray(0)); + this->V.insert(this->V.end(), this->TestPtrs.end(), this->TestPtrs.end()); + this->expectValues(this->V, this->testArray(0)); + this->V.insert(this->V.end(), this->TestPtrs.begin(), + llvm::next(this->TestPtrs.begin())); + this->expectValues(this->V, this->testArray(1)); + this->V.clear(); + this->V.insert(this->V.end(), this->TestPtrs.begin(), + llvm::next(this->TestPtrs.begin(), 2)); + this->expectValues(this->V, this->testArray(2)); + this->V.clear(); + this->V.insert(this->V.end(), this->TestPtrs.begin(), + llvm::next(this->TestPtrs.begin(), 42)); + this->expectValues(this->V, this->testArray(42)); + this->V.clear(); + this->V.insert(this->V.end(), + llvm::next(this->TestPtrs.begin(), 5), + llvm::next(this->TestPtrs.begin(), 13)); + this->V.insert(this->V.begin(), + llvm::next(this->TestPtrs.begin(), 0), + llvm::next(this->TestPtrs.begin(), 3)); + this->V.insert(llvm::next(this->V.begin(), 2), + llvm::next(this->TestPtrs.begin(), 2), + llvm::next(this->TestPtrs.begin(), 4)); + this->V.erase(llvm::next(this->V.begin(), 4)); + this->V.insert(llvm::next(this->V.begin(), 4), + llvm::next(this->TestPtrs.begin(), 4), + llvm::next(this->TestPtrs.begin(), 5)); + this->expectValues(this->V, this->testArray(13)); +} + }