diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-12 13:05:02 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-08-12 13:05:02 +0200 |
commit | ca524e5b70ccfeb6386cf0c5df83ffb86a8771fe (patch) | |
tree | 245c471373516ccda2b0c91943a42cd74674f2da /tests/auto/corelib/tools/qset/tst_qset.cpp | |
parent | b08cc0ec6f096d0e6764486c81264c24a406bee1 (diff) | |
parent | c2badc7423b63824902d1f44a4b804de3335c20b (diff) |
Merge remote-tracking branch 'origin/5.3' into 5.4
Manually included changes from
3a347a4e70e5a10ee92dd2578316c926a399e894
in src/opengl/qgl.cpp.
Conflicts:
src/opengl/qgl_qpa.cpp
src/plugins/platforms/android/androidjnimain.cpp
Change-Id: Ic26b58ee587d4884c9d0fba45c5a94b5a45ee929
Diffstat (limited to 'tests/auto/corelib/tools/qset/tst_qset.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qset/tst_qset.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 5ef1b44b6f..11873a7661 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -82,6 +82,13 @@ private slots: void initializerList(); }; +struct IdentityTracker { + int value, id; +}; + +inline uint qHash(IdentityTracker key) { return qHash(key.value); } +inline bool operator==(IdentityTracker lhs, IdentityTracker rhs) { return lhs.value == rhs.value; } + void tst_QSet::operator_eq() { { @@ -530,6 +537,18 @@ void tst_QSet::insert() QVERIFY(set1.size() == 2); QVERIFY(set1.contains(2)); } + + { + QSet<IdentityTracker> set; + QCOMPARE(set.size(), 0); + const int dummy = -1; + IdentityTracker id00 = {0, 0}, id01 = {0, 1}, searchKey = {0, dummy}; + QCOMPARE(set.insert(id00)->id, id00.id); + QCOMPARE(set.size(), 1); + QCOMPARE(set.insert(id01)->id, id00.id); // first inserted is kept + QCOMPARE(set.size(), 1); + QCOMPARE(set.find(searchKey)->id, id00.id); + } } void tst_QSet::setOperations() @@ -930,6 +949,13 @@ void tst_QSet::initializerList() QVERIFY(set.contains(4)); QVERIFY(set.contains(5)); + // check _which_ of the equal elements gets inserted (in the QHash/QMap case, it's the last): + const QSet<IdentityTracker> set2 = {{1, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}; + QCOMPARE(set2.count(), 5); + const int dummy = -1; + const IdentityTracker searchKey = {1, dummy}; + QCOMPARE(set2.find(searchKey)->id, 0); + QSet<int> emptySet{}; QVERIFY(emptySet.isEmpty()); |