diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-12-09 09:33:30 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-12-13 18:58:36 +0100 |
commit | e508c4c094230ad0de66120caf3a50688b829755 (patch) | |
tree | 6d677930d34a1fc5f1932f17a6c69a2729a81048 /tests/auto/corelib/tools | |
parent | 20d869f4c54ed1b2ae472af24c66b3ed779fa207 (diff) |
QCache: Adapt to upcoming QHash changes
QHash changes some of its preconditions, so we must not call
findNode without verifying !isEmpty()
Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I2701b9a01187530f541a7c9a12db56c92f856d87
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools')
-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 eb024e8f9e..58b8d6e4c6 100644 --- a/tests/auto/corelib/tools/qcache/tst_qcache.cpp +++ b/tests/auto/corelib/tools/qcache/tst_qcache.cpp @@ -37,6 +37,7 @@ public slots: void initTestCase(); void cleanupTestCase(); private slots: + void empty(); void maxCost(); void setMaxCost(); void totalCost(); @@ -75,6 +76,21 @@ void tst_QCache::cleanupTestCase() QCOMPARE(Foo::count, 0); } +void tst_QCache::empty() +{ + QCache<int, int> cache; + QCOMPARE(cache.size(), 0); + QCOMPARE(cache.count(), 0); + QVERIFY(cache.isEmpty()); + QVERIFY(!cache.contains(1)); + QCOMPARE(cache.keys().size(), 0); + QCOMPARE(cache.take(1), nullptr); + QVERIFY(!cache.remove(1)); + QCOMPARE(cache.object(1), nullptr); + QCOMPARE(cache[1], nullptr); + QCOMPARE(cache.totalCost(), 0); +} + void tst_QCache::maxCost() { QCache<QString, int> cache1, cache2(100), cache3(200), cache4(-50); |