From 23a49a637b65f1f16a5020230c946d894dae336a Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Sat, 31 Oct 2015 05:23:53 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251736 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/DenseMapTest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/unittests/ADT/DenseMapTest.cpp b/unittests/ADT/DenseMapTest.cpp index 2c6fe358832..f3dcf95e92f 100644 --- a/unittests/ADT/DenseMapTest.cpp +++ b/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(); -- 2.34.1