tst_QPixmapCache: rewrite QVERIFY(x != 0) to QVERIFY(x)
This is just confusing. QPixmapCache::find() already returns bool, comparing it to a literal zero just makes it hard to read. Change-Id: I43c000890377cca2111daa48799f10cc99aad8cf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 6032845ca2fc69fb67971ea9f7e06588ffcbe9f3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1f1dbb3633
commit
a10902ad35
@ -133,16 +133,16 @@ void tst_QPixmapCache::setCacheLimit()
|
||||
//The int part of the API
|
||||
p1 = new QPixmap(2, 3);
|
||||
QPixmapCache::Key key = QPixmapCache::insert(*p1);
|
||||
QVERIFY(QPixmapCache::find(key, p1) != 0);
|
||||
QVERIFY(QPixmapCache::find(key, p1));
|
||||
delete p1;
|
||||
|
||||
QPixmapCache::setCacheLimit(0);
|
||||
QVERIFY(QPixmapCache::find(key, p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, p1));
|
||||
|
||||
p1 = new QPixmap(2, 3);
|
||||
QPixmapCache::setCacheLimit(1000);
|
||||
QPixmapCache::replace(key, *p1);
|
||||
QVERIFY(QPixmapCache::find(key, p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, p1));
|
||||
|
||||
delete p1;
|
||||
|
||||
@ -151,10 +151,10 @@ void tst_QPixmapCache::setCacheLimit()
|
||||
QPixmapCache::clear();
|
||||
p1 = new QPixmap(2, 3);
|
||||
key = QPixmapCache::insert(*p1);
|
||||
QVERIFY(QPixmapCache::find(key, p1) != 0);
|
||||
QVERIFY(QPixmapCache::find(key, p1));
|
||||
p1->detach(); // dectach so that the cache thinks no-one is using it.
|
||||
QPixmapCache::setCacheLimit(0);
|
||||
QVERIFY(QPixmapCache::find(key, p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, p1));
|
||||
QPixmapCache::setCacheLimit(1000);
|
||||
key = QPixmapCache::insert(*p1);
|
||||
QVERIFY(key.isValid());
|
||||
@ -168,7 +168,7 @@ void tst_QPixmapCache::setCacheLimit()
|
||||
QPixmap p2;
|
||||
p1 = new QPixmap(2, 3);
|
||||
key = QPixmapCache::insert(*p1);
|
||||
QVERIFY(QPixmapCache::find(key, &p2) != 0);
|
||||
QVERIFY(QPixmapCache::find(key, &p2));
|
||||
//we flush the cache
|
||||
p1->detach();
|
||||
p2.detach();
|
||||
@ -176,8 +176,8 @@ void tst_QPixmapCache::setCacheLimit()
|
||||
QPixmapCache::setCacheLimit(1000);
|
||||
QPixmapCache::Key key2 = QPixmapCache::insert(*p1);
|
||||
QCOMPARE(getPrivate(key2)->key, 1);
|
||||
QVERIFY(QPixmapCache::find(key, &p2) == 0);
|
||||
QVERIFY(QPixmapCache::find(key2, &p2) != 0);
|
||||
QVERIFY(!QPixmapCache::find(key, &p2));
|
||||
QVERIFY(QPixmapCache::find(key2, &p2));
|
||||
QCOMPARE(p2, *p1);
|
||||
|
||||
delete p1;
|
||||
@ -200,7 +200,7 @@ void tst_QPixmapCache::setCacheLimit()
|
||||
QCOMPARE(getPrivate(key2)->key, 1);
|
||||
//This old key is not valid anymore after the flush
|
||||
QVERIFY(!key.isValid());
|
||||
QVERIFY(QPixmapCache::find(key, &p2) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, &p2));
|
||||
delete p1;
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ void tst_QPixmapCache::find()
|
||||
QPixmapCache::insert(p5);
|
||||
|
||||
//at that time the first key has been erase because no more place in the cache
|
||||
QVERIFY(QPixmapCache::find(key, &p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, &p1));
|
||||
QVERIFY(!key.isValid());
|
||||
}
|
||||
|
||||
@ -392,11 +392,11 @@ void tst_QPixmapCache::remove()
|
||||
QVERIFY(p1.toImage() == p1.toImage()); // sanity check
|
||||
|
||||
QPixmapCache::remove(key);
|
||||
QVERIFY(QPixmapCache::find(key, &p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(key, &p1));
|
||||
|
||||
//Broken key
|
||||
QPixmapCache::remove(QPixmapCache::Key());
|
||||
QVERIFY(QPixmapCache::find(QPixmapCache::Key(), &p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(QPixmapCache::Key(), &p1));
|
||||
|
||||
//Test if keys are release
|
||||
QPixmapCache::clear();
|
||||
@ -410,7 +410,7 @@ void tst_QPixmapCache::remove()
|
||||
QPixmapCache::clear();
|
||||
key = QPixmapCache::insert(p1);
|
||||
QCOMPARE(getPrivate(key)->key, 1);
|
||||
QVERIFY(QPixmapCache::find(key, &p1) != 0);
|
||||
QVERIFY(QPixmapCache::find(key, &p1));
|
||||
QPixmapCache::remove(key);
|
||||
QCOMPARE(p1.isDetached(), true);
|
||||
|
||||
@ -420,8 +420,8 @@ void tst_QPixmapCache::remove()
|
||||
QPixmapCache::insert("red", p1);
|
||||
key = QPixmapCache::insert(p1);
|
||||
QPixmapCache::remove(key);
|
||||
QVERIFY(QPixmapCache::find(key, &p1) == 0);
|
||||
QVERIFY(QPixmapCache::find("red", &p1) != 0);
|
||||
QVERIFY(!QPixmapCache::find(key, &p1));
|
||||
QVERIFY(QPixmapCache::find("red", &p1));
|
||||
}
|
||||
|
||||
void tst_QPixmapCache::clear()
|
||||
@ -465,7 +465,7 @@ void tst_QPixmapCache::clear()
|
||||
QPixmapCache::clear();
|
||||
|
||||
for (int k = 0; k < numberOfKeys; ++k) {
|
||||
QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0);
|
||||
QVERIFY(!QPixmapCache::find(keys.at(k), &p1));
|
||||
QVERIFY(!keys[k].isValid());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user