diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-02-25 23:35:13 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-02-25 23:35:13 +0000 |
commit | 0d64f8b0cab0273d3625cdf091a8ca7e2ccdb0c3 (patch) | |
tree | 7e85ff5538c654646b30c888bf09494dd0b9f757 /llvm/unittests/ADT/DenseMapTest.cpp | |
parent | c6f0a6ac27ce838e4dc803d9c7ed85a697697f97 (diff) | |
download | llvm-0d64f8b0cab0273d3625cdf091a8ca7e2ccdb0c3.zip llvm-0d64f8b0cab0273d3625cdf091a8ca7e2ccdb0c3.tar.gz llvm-0d64f8b0cab0273d3625cdf091a8ca7e2ccdb0c3.tar.bz2 |
fix crash in SmallDenseMap copy constructor
Prevent a crash in the SmallDenseMap copy constructor whenever the other
map is not in small mode.
<rdar://problem/14292693>
llvm-svn: 202206
Diffstat (limited to 'llvm/unittests/ADT/DenseMapTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/DenseMapTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp index fa5d0f2..dd49071 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -209,6 +209,34 @@ TYPED_TEST(DenseMapTest, CopyConstructorTest) { EXPECT_EQ(this->getValue(), copyMap[this->getKey()]); } +// Test copy constructor method where SmallDenseMap isn't small. +TYPED_TEST(DenseMapTest, CopyConstructorNotSmallTest) { + 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 copying from a default-constructed map. +TYPED_TEST(DenseMapTest, CopyConstructorFromDefaultTest) { + TypeParam copyMap(this->Map); + + EXPECT_TRUE(copyMap.empty()); +} + +// Test copying from an empty map where SmallDenseMap isn't small. +TYPED_TEST(DenseMapTest, CopyConstructorFromEmptyTest) { + for (int Key = 0; Key < 5; ++Key) + this->Map[this->getKey(Key)] = this->getValue(Key); + this->Map.clear(); + TypeParam copyMap(this->Map); + + EXPECT_TRUE(copyMap.empty()); +} + // Test assignment operator method TYPED_TEST(DenseMapTest, AssignmentTest) { this->Map[this->getKey()] = this->getValue(); |