diff options
author | Michael Gottesman <mgottesman@apple.com> | 2015-10-31 05:23:53 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2015-10-31 05:23:53 +0000 |
commit | ef711c18317c7c7463cfec0f7ee3d8974ba11966 (patch) | |
tree | ea1fdcb648d41a777e1ea655dc0587496fc25f4f | |
parent | 7791f1a4a952f28d1417a0fb05b94f15c98ddf91 (diff) | |
download | bcm5719-llvm-ef711c18317c7c7463cfec0f7ee3d8974ba11966.tar.gz bcm5719-llvm-ef711c18317c7c7463cfec0f7ee3d8974ba11966.zip |
Add a unittest for SmallDenseMap that tests assigning a SmallDenseMap when it is not small.
This complements CopyConstructorNotSmallTest. If we are testing the copy
constructor in such a way, we should also probably test assignment in the same
way.
llvm-svn: 251736
-rw-r--r-- | llvm/unittests/ADT/DenseMapTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp index 2c6fe358832..f3dcf95e92f 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -252,6 +252,22 @@ TYPED_TEST(DenseMapTest, AssignmentTest) { EXPECT_EQ(this->getValue(), copyMap[this->getKey()]); } +TYPED_TEST(DenseMapTest, AssignmentTestNotSmall) { + for (int Key = 0; Key < 5; ++Key) + this->Map[this->getKey(Key)] = this->getValue(Key); + TypeParam copyMap = this->Map; + + EXPECT_EQ(5u, copyMap.size()); + for (int Key = 0; Key < 5; ++Key) + EXPECT_EQ(this->getValue(Key), copyMap[this->getKey(Key)]); + + // test self-assignment. + copyMap = copyMap; + EXPECT_EQ(5u, copyMap.size()); + for (int Key = 0; Key < 5; ++Key) + EXPECT_EQ(this->getValue(Key), copyMap[this->getKey(Key)]); +} + // Test swap method TYPED_TEST(DenseMapTest, SwapTest) { this->Map[this->getKey()] = this->getValue(); |