summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qhash/tst_qhash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qhash/tst_qhash.cpp')
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 71428310b8..af1c7aed15 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -78,6 +78,7 @@ private slots:
void qthash_data();
void qthash();
+ void eraseValidIteratorOnSharedHash();
};
struct Foo {
@@ -1352,5 +1353,34 @@ void tst_QHash::qthash()
QTEST(result, "hash");
}
+void tst_QHash::eraseValidIteratorOnSharedHash()
+{
+ QHash<int, int> a, b;
+ a.insert(10, 10);
+ a.insertMulti(10, 25);
+ a.insertMulti(10, 30);
+ a.insert(20, 20);
+ a.insert(40, 40);
+
+ QHash<int, int>::iterator i = a.begin();
+ while (i.value() != 25)
+ ++i;
+
+ b = a;
+ a.erase(i);
+
+ QCOMPARE(b.size(), 5);
+ QCOMPARE(a.size(), 4);
+
+ for (i = a.begin(); i != a.end(); ++i)
+ QVERIFY(i.value() != 25);
+
+ int itemsWith10 = 0;
+ for (i = b.begin(); i != b.end(); ++i)
+ itemsWith10 += (i.key() == 10);
+
+ QCOMPARE(itemsWith10, 3);
+}
+
QTEST_APPLESS_MAIN(tst_QHash)
#include "tst_qhash.moc"