diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-01-23 14:59:35 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-04-09 20:03:03 +0200 |
commit | e1e573cee8f0197a1549929dc9e818f8004fb1cb (patch) | |
tree | 8e69848165187b7cafd11a0a71b3e05de679d4be /tests/auto/corelib/tools/qcache/tst_qcache.cpp | |
parent | 5b7c3e31b538376f2b4733bd868b5875b504cdb3 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qcache/tst_qcache.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qcache/tst_qcache.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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<int, int>) == sizeof(void *)); } +void tst_QCache::largeCache() +{ + QCache<int, int> 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" |