From a10902ad35fe91799a5ce221ab7620a2681c4527 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 7 Jun 2023 16:33:17 +0200 Subject: [PATCH] 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 (cherry picked from commit 6032845ca2fc69fb67971ea9f7e06588ffcbe9f3) Reviewed-by: Qt Cherry-pick Bot --- .../image/qpixmapcache/tst_qpixmapcache.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp index b3fee697088..227e7b60af1 100644 --- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -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()); } }