diff --git a/src/core/qgstestutils.h b/src/core/qgstestutils.h index 32da3b5ae32..13c4687ca41 100644 --- a/src/core/qgstestutils.h +++ b/src/core/qgstestutils.h @@ -23,7 +23,14 @@ * @note added in QGIS 2.16 */ -#define QGSCOMPARENEAR(a,b,epsilon) { bool _xxxresult = qgsDoubleNear( a, b, epsilon ); if ( !_xxxresult ) { qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( a ), static_cast< double >( b ), qAbs( static_cast< double >( a ) - b ), static_cast< double >( epsilon ) ); } QVERIFY( _xxxresult ); } +#define QGSCOMPARENEAR(a,b,epsilon) { \ + bool _xxxresult = qgsDoubleNear( a, b, epsilon ); \ + if ( !_xxxresult ) \ + { \ + qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( a ), static_cast< double >( b ), qAbs( static_cast< double >( a ) - b ), static_cast< double >( epsilon ) ); \ + } \ + QVERIFY( qgsDoubleNear( a, b, epsilon ) ); \ +} #endif // QGSTESTUTILS_H diff --git a/tests/src/core/testqgsgeometryutils.cpp b/tests/src/core/testqgsgeometryutils.cpp index 12c54858805..0b597a8f819 100644 --- a/tests/src/core/testqgsgeometryutils.cpp +++ b/tests/src/core/testqgsgeometryutils.cpp @@ -19,6 +19,7 @@ #include "qgslinestringv2.h" #include "qgspolygonv2.h" #include "qgsmultipolygonv2.h" +#include "qgstestutils.h" class TestQgsGeometryUtils: public QObject { @@ -413,8 +414,7 @@ void TestQgsGeometryUtils::testSqrDistToLine() p1.x(), p1.y(), p2.x(), p2.y(), rx, ry, epsilon ); - sqrDist = qRound( sqrDist * 100 ) / 100; - QCOMPARE( sqrDist, 11.83 ); + QGSCOMPARENEAR( sqrDist, 11.83, 0.01 ); }