summaryrefslogtreecommitdiff
path: root/unittests/ADT
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-04-26 18:45:24 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-04-26 18:45:24 +0000
commit5c77bc29db1ddf4664c2ed16da9da08d29ab3226 (patch)
tree0886f27c4c34611a915222f6f5b08e800ca351cc /unittests/ADT
parent37abe8df4a4e74513e2daa0cdf0b801bec94dade (diff)
downloadllvm-5c77bc29db1ddf4664c2ed16da9da08d29ab3226.tar.gz
llvm-5c77bc29db1ddf4664c2ed16da9da08d29ab3226.tar.bz2
llvm-5c77bc29db1ddf4664c2ed16da9da08d29ab3226.tar.xz
Fixed SmallMap test. The order of items is undefined in DenseMap. So being checking the increment for big mode, we can only check that all items are in map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r--unittests/ADT/SmallMapTest.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/unittests/ADT/SmallMapTest.cpp b/unittests/ADT/SmallMapTest.cpp
index 91319dede2..b2079243fd 100644
--- a/unittests/ADT/SmallMapTest.cpp
+++ b/unittests/ADT/SmallMapTest.cpp
@@ -45,11 +45,6 @@ TEST(SmallMapTest, GeneralTest) {
found = a.find(&buf[8]);
EXPECT_EQ(found, a.end());
- // Check increment for small mode.
- found = a.begin();
- ++found;
- EXPECT_EQ(found->second, 10);
-
b.insert(std::make_pair(&buf[2], 2));
std::swap(a, b);
@@ -82,11 +77,6 @@ TEST(SmallMapTest, GeneralTest) {
found = b.find(&buf[8]);
EXPECT_EQ(found, b.end());
- // Check increment for big mode.
- found = b.find(&buf[1]);
- ++found;
- EXPECT_EQ(found->second, 14);
-
std::swap(a, b);
a.swap(b);
std::swap(a, b);
@@ -130,4 +120,28 @@ TEST(SmallMapTest, GeneralTest) {
SmallMap<int *, int, 3>::value_type Buf7;
Buf7 = a.FindAndConstruct(&buf[7]);
EXPECT_EQ(Buf7.second, 0);
+
+ // Check increments
+
+ SmallMap<int *, int, 2> c;
+ c.insert(std::make_pair(&buf[0], 0));
+ c.insert(std::make_pair(&buf[1], 1));
+
+ // For small mode we know that flat array map is used and we know the
+ // order of items.
+ unsigned ii = 0;
+ for (SmallMap<int *, int, 2>::iterator i = c.begin(), e = c.end();
+ i != e; ++i, ++ii) {
+ EXPECT_TRUE((i->first == &buf[0] && i->second == 0 && ii == 0) ||
+ (i->first == &buf[1] && i->second == 1 && ii == 1));
+ }
+
+ // For big mode DenseMap is used and final order of items is undefined.
+ c.insert(std::make_pair(&buf[2], 2));
+ for (SmallMap<int *, int, 2>::iterator i = c.begin(), e = c.end();
+ i != e; ++i) {
+ EXPECT_TRUE((i->first == &buf[0] && i->second == 0) ||
+ (i->first == &buf[1] && i->second == 1) ||
+ (i->first == &buf[2] && i->second == 2));
+ }
}