summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-07-12 10:10:38 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-07-27 17:44:30 +0200
commit8c49ae522d184deb5a9118ba2368629709ff6e85 (patch)
tree877f1302e2ac2cfc82555ddf4a71d303a9dd4465 /tests/auto/corelib/tools
parent6b400e3147dcfd8cc3a393ace1bd118c93762e0c (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. Pick-to: 6.2 Change-Id: I4f8f0e60c810acdc666cf34f929845227ed87f3b Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-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 6462ef0dd7..12a4103060 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
@@ -172,12 +178,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));
+ }
}
}