From 23306a399c0703eea7420231903c850566bfe2f0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Jun 2010 21:01:36 +0200 Subject: Make tst_image a little bit more tollerent to rounding errors --- tests/auto/qimage/tst_qimage.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 10514d9..2164b05 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -1426,11 +1426,6 @@ static inline int rand8() return int(256. * (qrand() / (RAND_MAX + 1.0))); } -static inline bool compare(int a, int b, int tolerance) -{ - return qAbs(a - b) <= tolerance; -} - // compares img.scale against the bilinear filtering used by QPainter void tst_QImage::smoothScale3() { @@ -1458,6 +1453,7 @@ void tst_QImage::smoothScale3() p.scale(scales[i], scales[i]); p.drawImage(0, 0, img); p.end(); + int err = 0; for (int y = 0; y < a.height(); ++y) { for (int x = 0; x < a.width(); ++x) { @@ -1465,11 +1461,15 @@ void tst_QImage::smoothScale3() QRgb cb = b.pixel(x, y); // tolerate a little bit of rounding errors - QVERIFY(compare(qRed(ca), qRed(cb), 16)); - QVERIFY(compare(qGreen(ca), qGreen(cb), 16)); - QVERIFY(compare(qBlue(ca), qBlue(cb), 16)); + bool r = true; + r &= qAbs(qRed(ca) - qRed(cb)) <= 18; + r &= qAbs(qGreen(ca) - qGreen(cb)) <= 18; + r &= qAbs(qBlue(ca) - qBlue(cb)) <= 18; + if (!r) + err++; } } + QCOMPARE(err, 0); } } -- cgit v0.12