[llvm] r251736 - Add a unittest for SmallDenseMap that tests assigning a SmallDenseMap when it is not small.
Michael Gottesman via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 30 22:23:53 PDT 2015
Author: mgottesman
Date: Sat Oct 31 00:23:53 2015
New Revision: 251736
URL: http://llvm.org/viewvc/llvm-project?rev=251736&view=rev
Log:
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.
Modified:
llvm/trunk/unittests/ADT/DenseMapTest.cpp
Modified: llvm/trunk/unittests/ADT/DenseMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseMapTest.cpp?rev=251736&r1=251735&r2=251736&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/DenseMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/DenseMapTest.cpp Sat Oct 31 00:23:53 2015
@@ -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();
More information about the llvm-commits
mailing list