summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimage
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-06-07 19:01:36 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-06-07 19:01:36 (GMT)
commit23306a399c0703eea7420231903c850566bfe2f0 (patch)
tree58070cba417611a09ec14c77b2973c3b8344eaae /tests/auto/qimage
parent29ef46edfd4f01da7d79338c031b237af415be3a (diff)
downloadQt-23306a399c0703eea7420231903c850566bfe2f0.zip
Qt-23306a399c0703eea7420231903c850566bfe2f0.tar.gz
Qt-23306a399c0703eea7420231903c850566bfe2f0.tar.bz2
Make tst_image a little bit more tollerent to rounding errors
Diffstat (limited to 'tests/auto/qimage')
-rw-r--r--tests/auto/qimage/tst_qimage.cpp16
1 files 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);
}
}