Condense qgstestutils.h and qgstest.h into a single file

This commit is contained in:
Nyall Dawson 2017-09-04 10:38:18 +10:00
parent 2286710606
commit 700f9b2ef8
36 changed files with 36 additions and 97 deletions

View File

@ -868,7 +868,6 @@ SET(QGIS_CORE_HDRS
qgsstatisticalsummary.h
qgsstringstatisticalsummary.h
qgsstringutils.h
qgstestutils.h
qgstextlabelfeature.h
qgstextrenderer.h
qgstextrenderer_p.h

View File

@ -1,63 +0,0 @@
/***************************************************************************
qgstestutils.h
---------------------
begin : June 2016
copyright : (C) 2016 by Nyall Dawson
email : nyalld dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSTESTUTILS_H
#define QGSTESTUTILS_H
#define SIP_NO_FILE
#include "qgis.h"
#include "QtTest/qtestcase.h"
/** \ingroup core
* Assorted helper methods for unit testing.
* \since QGIS 2.16
*/
#define QGSCOMPARENEAR(value,expected,epsilon) { \
bool _xxxresult = qgsDoubleNear( value, expected, epsilon ); \
if ( !_xxxresult ) \
{ \
qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), std::fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \
}
#define QGSCOMPARENOTNEAR(value,not_expected,epsilon) { \
bool _xxxresult = qgsDoubleNear( value, not_expected, epsilon ); \
if ( _xxxresult ) \
{ \
qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), std::fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( !qgsDoubleNear( value, not_expected, epsilon ) ); \
}
#define QGSCOMPARENEARPOINT(point1,point2,epsilon) { \
QGSCOMPARENEAR( point1.x(), point2.x(), epsilon ); \
QGSCOMPARENEAR( point1.y(), point2.y(), epsilon ); \
}
#define QGSCOMPARENEARRECTANGLE(rectangle1,rectangle2,epsilon) { \
QGSCOMPARENEAR( rectangle1.xMinimum(), rectangle2.xMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.xMaximum(), rectangle2.xMaximum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMinimum(), rectangle2.yMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
}
//sometimes GML attributes are in a different order - but that's ok
#define QGSCOMPAREGML(result,expected) { \
QCOMPARE( result.replace( QStringLiteral("ts=\" \" cs=\",\""), QStringLiteral("cs=\",\" ts=\" \"") ), expected ); \
}
#endif // QGSTESTUTILS_H

View File

@ -34,6 +34,42 @@
return QTest::qExec(&tc, argc, argv); \
}
#define QGSCOMPARENEAR(value,expected,epsilon) { \
bool _xxxresult = qgsDoubleNear( value, expected, epsilon ); \
if ( !_xxxresult ) \
{ \
qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), std::fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \
}
#define QGSCOMPARENOTNEAR(value,not_expected,epsilon) { \
bool _xxxresult = qgsDoubleNear( value, not_expected, epsilon ); \
if ( _xxxresult ) \
{ \
qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), std::fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( !qgsDoubleNear( value, not_expected, epsilon ) ); \
}
#define QGSCOMPARENEARPOINT(point1,point2,epsilon) { \
QGSCOMPARENEAR( point1.x(), point2.x(), epsilon ); \
QGSCOMPARENEAR( point1.y(), point2.y(), epsilon ); \
}
#define QGSCOMPARENEARRECTANGLE(rectangle1,rectangle2,epsilon) { \
QGSCOMPARENEAR( rectangle1.xMinimum(), rectangle2.xMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.xMaximum(), rectangle2.xMaximum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMinimum(), rectangle2.yMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
}
//sometimes GML attributes are in a different order - but that's ok
#define QGSCOMPAREGML(result,expected) { \
QCOMPARE( result.replace( QStringLiteral("ts=\" \" cs=\",\""), QStringLiteral("cs=\",\" ts=\" \"") ), expected ); \
}
/**
* QGIS unit test utilities.
* \since QGIS 3.0

View File

@ -19,7 +19,6 @@
#include "qgsapplication.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsrectangle.h"
#include "qgstestutils.h"
#include <QDir>

View File

@ -21,7 +21,6 @@ Email : nyall dot dawson at gmail dot com
#include "qgsrastermatrix.h"
#include "qgsapplication.h"
#include "qgsproject.h"
#include "qgstestutils.h"
Q_DECLARE_METATYPE( QgsRasterCalcNode::Operator )

View File

@ -28,7 +28,6 @@
#include "qgsvectorfilewriter.h"
#include "qgstest.h"
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the attribute table dialog

View File

@ -24,7 +24,6 @@
#include "qgsproject.h"
#include "qgsmapcanvas.h"
#include "qgsunittypes.h"
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the field calculator

View File

@ -26,7 +26,6 @@
#include "qgsunittypes.h"
#include "qgsmaptoolidentifyaction.h"
#include "qgssettings.h"
#include "qgstestutils.h"
#include "cpl_conv.h"

View File

@ -24,7 +24,6 @@
#include "qgsproject.h"
#include "qgsmapcanvas.h"
#include "qgsunittypes.h"
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the measure tool

View File

@ -29,7 +29,6 @@
#include "qgsproperty.h"
#include <QObject>
#include "qgstest.h"
#include "qgstestutils.h"
class TestQgsComposerMap : public QObject
{

View File

@ -22,7 +22,6 @@
#include "qgsmultirenderchecker.h"
#include "qgsfontutils.h"
#include "qgsproject.h"
#include "qgstestutils.h"
#include "qgsproperty.h"
#include <QObject>
#include "qgstest.h"

View File

@ -37,7 +37,6 @@
#include <QObject>
#include "qgstest.h"
#include "qgstestutils.h"
class TestQgsComposition : public QObject
{

View File

@ -19,7 +19,6 @@
#include "qgsrectangle.h"
#include <QObject>
#include "qgstest.h"
#include "qgstestutils.h"
class TestQgsCoordinateTransform: public QObject
{

View File

@ -25,7 +25,6 @@
#include "qgslinestring.h"
#include "qgspoint.h"
#include "qgstest.h"
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the operations on curve geometries

View File

@ -26,7 +26,6 @@
#include "qgsgeometryfactory.h"
#include "qgsgeometry.h"
#include "qgis.h"
#include "qgstestutils.h"
#include <memory>
class TestQgsDistanceArea: public QObject

View File

@ -33,7 +33,6 @@
#include "qgsrasterlayer.h"
#include "qgsproject.h"
#include "qgsexpressionnodeimpl.h"
#include "qgstestutils.h"
static void _parseAndEvalExpr( int arg )
{

View File

@ -44,7 +44,6 @@
#include "qgscircularstring.h"
#include "qgsgeometrycollection.h"
#include "qgsgeometryfactory.h"
#include "qgstestutils.h"
//qgs unit test utility class
#include "qgsrenderchecker.h"

View File

@ -21,7 +21,6 @@
#include "qgstest.h"
#include "qgstestutils.h"
#include <QObject>

View File

@ -19,7 +19,6 @@
#include "qgslinestring.h"
#include "qgspolygon.h"
#include "qgsmultipolygon.h"
#include "qgstestutils.h"
class TestQgsGeometryUtils: public QObject
{

View File

@ -20,7 +20,6 @@
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgshistogram.h"
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for QgsHistogram

View File

@ -20,7 +20,6 @@
#include "qgsproject.h"
#include "qgslayoutitemmap.h"
#include "qgslayoutitemshape.h"
#include "qgstestutils.h"
class TestQgsLayout: public QObject
{

View File

@ -22,7 +22,6 @@
#include "qgstest.h"
#include "qgsproject.h"
#include "qgsreadwritecontext.h"
#include "qgstestutils.h"
#include <QObject>
#include <QPainter>
#include <QImage>

View File

@ -23,7 +23,6 @@
#include "qgslayoutsize.h"
#include "qgslayoutmeasurementconverter.h"
#include "qgis.h"
#include "qgstestutils.h"
class TestQgsLayoutUnits : public QObject
{

View File

@ -18,7 +18,6 @@
#include "qgslayout.h"
#include "qgstest.h"
#include "qgslayoututils.h"
#include "qgstestutils.h"
#include "qgsproject.h"
#include "qgslayoutitemmap.h"

View File

@ -20,7 +20,6 @@
#include <qgsmaptopixel.h>
#include <qgspoint.h>
#include "qgslogger.h"
#include "qgstestutils.h"
class TestQgsMapToPixel: public QObject
{

View File

@ -25,7 +25,6 @@
#include <qgsgeometry.h>
//header for class being tested
#include <qgspoint.h>
#include "qgstestutils.h"
class TestQgsPointXY: public QObject
{

View File

@ -25,7 +25,6 @@
#include <QtTest/QSignalSpy>
#include "qgis.h"
#include "qgstest.h"
#include "qgstestutils.h"
#include "qgsrasterlayer.h"
#include "qgsproject.h"
#include "qgspoint.h"

View File

@ -16,7 +16,6 @@
***************************************************************************/
#include "qgstest.h"
#include "qgstestutils.h"
#include "qgsproperty.h"
#include "qgspropertycollection.h"
#include "qgsvectorlayer.h"

View File

@ -45,7 +45,6 @@
//qgis unit test includes
#include <qgsrenderchecker.h>
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the QgsRasterLayer class.

View File

@ -39,7 +39,6 @@
//qgis unit test includes
#include <qgsrenderchecker.h>
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for raster sublayers

View File

@ -20,7 +20,6 @@
#include "qgsstatisticalsummary.h"
#include "qgis.h"
#include "qgstestutils.h"
class TestQgsStatisticSummary: public QObject
{

View File

@ -17,7 +17,6 @@
#include <qgsapplication.h>
#include <qgsgeometry.h>
#include <qgstestutils.h>
#include <qgstracer.h>
#include <qgsvectorlayer.h>

View File

@ -23,7 +23,6 @@
#include "qgsrasterlayer.h"
#include <QObject>
#include "qgstest.h"
#include "qgstestutils.h"
class TestProjectionIssues : public QObject
{

View File

@ -23,7 +23,6 @@
#include "qgslayoutitemregistry.h"
#include "qgslayoutitemguiregistry.h"
#include "qgslayoutitemwidget.h"
#include "qgstestutils.h"
#include "qgsproject.h"
#include "qgsgui.h"
#include <QtTest/QSignalSpy>

View File

@ -22,7 +22,6 @@
#include <qgsrenderchecker.h>
#include <qgsvectordataprovider.h>
#include <qgsmaptoolpan.h>
#include "qgstestutils.h"
namespace QTest
{

View File

@ -29,7 +29,6 @@
#include <qgsproviderregistry.h>
#include <qgsrasterdataprovider.h>
#include <qgsrectangle.h>
#include "qgstestutils.h"
/** \ingroup UnitTests
* This is a unit test for the gdal provider