summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qcache/tst_qcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qcache/tst_qcache.cpp')
-rw-r--r--tests/auto/corelib/tools/qcache/tst_qcache.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qcache/tst_qcache.cpp b/tests/auto/corelib/tools/qcache/tst_qcache.cpp
index 54cf00f9da..da6f1bb34b 100644
--- a/tests/auto/corelib/tools/qcache/tst_qcache.cpp
+++ b/tests/auto/corelib/tools/qcache/tst_qcache.cpp
@@ -49,6 +49,7 @@ private slots:
void axioms_on_key_type();
void largeCache();
void internalChainOrderAfterEntryUpdate();
+ void emplaceLowerCost();
};
@@ -431,5 +432,18 @@ void tst_QCache::internalChainOrderAfterEntryUpdate()
QCOMPARE(cache.size(), 0);
}
+void tst_QCache::emplaceLowerCost()
+{
+ QCache<QString, int> cache;
+ cache.setMaxCost(5);
+ cache.insert("a", new int, 3); // insert high cost
+ cache.insert("a", new int, 1); // and then exchange it with a lower-cost object
+ QCOMPARE(cache.totalCost(), 1);
+ cache.remove("a"); // then remove the object
+ // The cache should now have a cost == 0 and be empty.
+ QCOMPARE(cache.totalCost(), 0);
+ QVERIFY(cache.isEmpty());
+}
+
QTEST_APPLESS_MAIN(tst_QCache)
#include "tst_qcache.moc"