diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-06-07 19:01:36 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-31 08:38:41 (GMT) |
commit | 1a72dd3a1c8f66e31ce4102b2d3e7e5cff4817f8 (patch) | |
tree | b8fa70f12adbfa4d0c08487b8b68fef5ba89774d /tests/auto/qimage | |
parent | 34d0cd1e65644970d890e52bd3c880fc941d99f9 (diff) | |
download | Qt-1a72dd3a1c8f66e31ce4102b2d3e7e5cff4817f8.zip Qt-1a72dd3a1c8f66e31ce4102b2d3e7e5cff4817f8.tar.gz Qt-1a72dd3a1c8f66e31ce4102b2d3e7e5cff4817f8.tar.bz2 |
Make tst_image a little bit more tollerent to rounding errors
(cherry picked from commit 23306a399c0703eea7420231903c850566bfe2f0)
Diffstat (limited to 'tests/auto/qimage')
-rw-r--r-- | tests/auto/qimage/tst_qimage.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 405eb98..ec0ecec 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -1451,11 +1451,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() { @@ -1483,6 +1478,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) { @@ -1490,11 +1486,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); } } |