aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-05-15 09:21:39 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-05-15 09:21:39 +0000
commit661f760320e8b8e9bd44016585648bb1941b1584 (patch)
tree41cc3f83fcb79c7ea5def2c6d73183d2c8ee9d91 /unittests
parentc2c52a647098e72558f1831b7502a79fd22ead31 (diff)
downloadexternal_llvm-661f760320e8b8e9bd44016585648bb1941b1584.zip
external_llvm-661f760320e8b8e9bd44016585648bb1941b1584.tar.gz
external_llvm-661f760320e8b8e9bd44016585648bb1941b1584.tar.bz2
Fixed one small stupid, but critical bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/SmallMapTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/ADT/SmallMapTest.cpp b/unittests/ADT/SmallMapTest.cpp
index b207924..10ba0ef 100644
--- a/unittests/ADT/SmallMapTest.cpp
+++ b/unittests/ADT/SmallMapTest.cpp
@@ -144,4 +144,19 @@ TEST(SmallMapTest, GeneralTest) {
(i->first == &buf[1] && i->second == 1) ||
(i->first == &buf[2] && i->second == 2));
}
+
+ // Check that iteration only visits elements that actually exist.
+ SmallMap<int, int, 8> d;
+ d[0] = 2;
+ d[1] = 3;
+ unsigned counts[2] = { 0, 0 };
+ for (SmallMap<int, int, 8>::iterator I = d.begin(), E = d.end(); I != E;
+ ++I) {
+ EXPECT_TRUE(I->first == 0 || I->first == 1);
+ EXPECT_TRUE(I->second == 2 || I->second == 3);
+ EXPECT_EQ(I->second, I->first + 2);
+ ++counts[I->first];
+ }
+ EXPECT_EQ(counts[0], 1);
+ EXPECT_EQ(counts[1], 1);
}