tst_QPainterPath::testNaNandInfinites(): anticipate the warnings

The test used to trigger a lot of QWARN messages; these are clearly
intended, so tell QTest to expect them, so that we get an error here
if those warnings ever don't show up.

Incidentally tidy up a comment and convert a != verify to a
QCOMPARE_NE(), since it's now available to do that job.

Change-Id: I83e225c37abe8446dac06ebe4e75258cb87b71b0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Edward Welbourne 2022-10-07 19:33:50 +02:00
parent 4af55438d0
commit bed8663a0b

View File

@ -1220,38 +1220,65 @@ void tst_QPainterPath::testNaNandInfinites()
QPointF p3 = QPointF(qQNaN(), 1);
QPointF pInf = QPointF(qInf(), 1);
// all these operations with NaN/Inf should be ignored
// can't test operator>> reliably, as we can't create a path with NaN to << later
// All these operations with NaN/Inf should be ignored.
// Can't test operator>> reliably, as we can't create a path with NaN to << later.
#ifdef QT_NO_DEBUG
# define WARNS(name)
#else
# define WARNS(name) \
QTest::ignoreMessage(QtWarningMsg, "QPainterPath::" #name ": " \
"Adding point with invalid coordinates, ignoring call")
#endif
WARNS(moveTo);
path1.moveTo(p1);
WARNS(moveTo);
path1.moveTo(qSNaN(), qQNaN());
WARNS(moveTo);
path1.moveTo(pInf);
WARNS(lineTo);
path1.lineTo(p1);
WARNS(lineTo);
path1.lineTo(qSNaN(), qQNaN());
WARNS(lineTo);
path1.lineTo(pInf);
WARNS(cubicTo);
path1.cubicTo(p1, p2, p3);
WARNS(cubicTo);
path1.cubicTo(p1, QPointF(1, 1), QPointF(2, 2));
WARNS(cubicTo);
path1.cubicTo(pInf, QPointF(10, 10), QPointF(5, 1));
WARNS(quadTo);
path1.quadTo(p1, p2);
WARNS(quadTo);
path1.quadTo(QPointF(1, 1), p3);
WARNS(quadTo);
path1.quadTo(QPointF(1, 1), pInf);
WARNS(arcTo);
path1.arcTo(QRectF(p1, p2), 5, 5);
WARNS(arcTo);
path1.arcTo(QRectF(pInf, QPointF(1, 1)), 5, 5);
WARNS(addRect);
path1.addRect(QRectF(p1, p2));
WARNS(addRect);
path1.addRect(QRectF(pInf, QPointF(1, 1)));
WARNS(addEllipse);
path1.addEllipse(QRectF(p1, p2));
WARNS(addEllipse);
path1.addEllipse(QRectF(pInf, QPointF(1, 1)));
#undef WARNS
QCOMPARE(path1, path2);
path1.lineTo(QPointF(1, 1));
QVERIFY(path1 != path2);
QCOMPARE_NE(path1, path2);
}
#endif // signaling_nan