From e1e573cee8f0197a1549929dc9e818f8004fb1cb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 23 Jan 2020 14:59:35 +0100 Subject: new QCache implementation Make use of the new features available in QHash and do a more performant implementation than the old one. Change-Id: Ie74b3cdcc9871cd241aca205672093dc395d04a7 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qcache/tst_qcache.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto/corelib/tools') diff --git a/tests/auto/corelib/tools/qcache/tst_qcache.cpp b/tests/auto/corelib/tools/qcache/tst_qcache.cpp index d880953c1c..af74553ab4 100644 --- a/tests/auto/corelib/tools/qcache/tst_qcache.cpp +++ b/tests/auto/corelib/tools/qcache/tst_qcache.cpp @@ -47,6 +47,7 @@ private slots: void remove(); void take(); void axioms_on_key_type(); + void largeCache(); }; @@ -398,5 +399,20 @@ void tst_QCache::axioms_on_key_type() QVERIFY(sizeof(QHash) == sizeof(void *)); } +void tst_QCache::largeCache() +{ + QCache cache; + cache.setMaxCost(500); + for (int i = 0; i < 1000; ++i) { + for (int j = 0; j < qMax(0, i - 500); ++j) + QVERIFY(!cache.contains(j)); + for (int j = qMax(0, i - 500); j < i; ++j) + QVERIFY(cache.contains(j)); + cache.insert(i, new int); + } + cache.clear(); + QVERIFY(cache.size() == 0); +} + QTEST_APPLESS_MAIN(tst_QCache) #include "tst_qcache.moc" -- cgit v1.2.3