summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-07-12 10:10:38 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-27 18:36:28 +0000
commit28ce15041c4a9bc2d03f657b35ac1edc692a79f4 (patch)
tree51bc942c883c7717e9d5781f8efdc72769aa7c3f /tests/auto/corelib
parent202143ba41f6ac574f1858214ed8bf4a38b73ccd (diff)
QDuplicateTracker: bring back appendTo() &&
This reverts commit c19695ab953c979f15bbc72c4f4a453e9a114cf6. Just because QSet has limited API doesn't mean we can't provide this in an efficient way for std::unordered_set :P Added tests. Change-Id: I4f8f0e60c810acdc666cf34f929845227ed87f3b Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 8c49ae522d184deb5a9118ba2368629709ff6e85) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qduplicatetracker/tst_qduplicatetracker.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/tests/auto/corelib/tools/qduplicatetracker/tst_qduplicatetracker.cpp b/tests/auto/corelib/tools/qduplicatetracker/tst_qduplicatetracker.cpp
index f4f038ca94..41a1e791a7 100644
--- a/tests/auto/corelib/tools/qduplicatetracker/tst_qduplicatetracker.cpp
+++ b/tests/auto/corelib/tools/qduplicatetracker/tst_qduplicatetracker.cpp
@@ -94,9 +94,15 @@ void tst_QDuplicateTracker::appendTo()
QVERIFY(!tracker.hasSeen(2));
QList<int> c;
- tracker.appendTo(c);
+ std::move(tracker).appendTo(c);
std::sort(c.begin(), c.end());
QCOMPARE(c, QList<int>({ 0, 1, 2 }));
+ if (QDuplicateTracker<int, 2>::uses_pmr) {
+ // the following is only true if we use the std container
+ QVERIFY(!tracker.hasSeen(0));
+ QVERIFY(!tracker.hasSeen(1));
+ QVERIFY(!tracker.hasSeen(2));
+ }
}
struct ConstructionCounted
@@ -173,12 +179,36 @@ void tst_QDuplicateTracker::appendTo_special()
QVERIFY(!tracker.hasSeen(1));
QVERIFY(!tracker.hasSeen(2));
QVERIFY(!tracker.hasSeen(3));
- QList<ConstructionCounted> a;
- a.reserve(3);
- tracker.appendTo(a);
- for (const auto &counter : a) {
- QCOMPARE(counter.moves, 1);
- QCOMPARE(counter.copies, 1);
+
+ QVERIFY(tracker.hasSeen(1));
+ QVERIFY(tracker.hasSeen(2));
+ QVERIFY(tracker.hasSeen(3));
+ {
+ QList<ConstructionCounted> a;
+ a.reserve(3);
+ tracker.appendTo(a);
+ for (const auto &counter : a) {
+ QCOMPARE(counter.moves, 1);
+ QCOMPARE(counter.copies, 1);
+ }
+ }
+ QVERIFY(tracker.hasSeen(1));
+ QVERIFY(tracker.hasSeen(2));
+ QVERIFY(tracker.hasSeen(3));
+ {
+ QList<ConstructionCounted> a;
+ a.reserve(3);
+ std::move(tracker).appendTo(a);
+ if (QDuplicateTracker<ConstructionCounted>::uses_pmr) {
+ // the following is only true if we use the std container
+ for (const auto &counter : a) {
+ QCOMPARE(counter.moves, 2);
+ QCOMPARE(counter.copies, 0);
+ }
+ QVERIFY(!tracker.hasSeen(1));
+ QVERIFY(!tracker.hasSeen(2));
+ QVERIFY(!tracker.hasSeen(3));
+ }
}
}