26
26
#include " qgsunittypes.h"
27
27
#include " qgsmaptoolidentifyaction.h"
28
28
#include " qgssettings.h"
29
+ #include " qgstestutils.h"
29
30
30
31
#include " cpl_conv.h"
31
32
@@ -142,23 +143,23 @@ void TestQgsMapToolIdentifyAction::lengthCalculation()
142
143
QCOMPARE ( result.length (), 1 );
143
144
QString derivedLength = result.at ( 0 ).mDerivedAttributes [tr ( " Length" )];
144
145
double length = derivedLength.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
145
- QVERIFY ( qgsDoubleNear ( length, 26932.2 , 0.1 ) );
146
+ QGSCOMPARENEAR ( length, 26932.2 , 0.1 );
146
147
147
148
// check that project units are respected
148
149
QgsProject::instance ()->setDistanceUnits ( QgsUnitTypes::DistanceFeet );
149
150
result = action->identify ( mapPoint.x (), mapPoint.y (), QList<QgsMapLayer *>() << tempLayer.get () );
150
151
QCOMPARE ( result.length (), 1 );
151
152
derivedLength = result.at ( 0 ).mDerivedAttributes [tr ( " Length" )];
152
153
length = derivedLength.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
153
- QVERIFY ( qgsDoubleNear ( length, 88360.1 , 0.1 ) );
154
+ QGSCOMPARENEAR ( length, 88360.1 , 0.1 );
154
155
155
156
// test unchecked "keep base units" setting
156
157
s.setValue ( QStringLiteral ( " /qgis/measure/keepbaseunit" ), false );
157
158
result = action->identify ( mapPoint.x (), mapPoint.y (), QList<QgsMapLayer *>() << tempLayer.get () );
158
159
QCOMPARE ( result.length (), 1 );
159
160
derivedLength = result.at ( 0 ).mDerivedAttributes [tr ( " Length" )];
160
161
length = derivedLength.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
161
- QVERIFY ( qgsDoubleNear ( length, 16.735 , 0.001 ) );
162
+ QGSCOMPARENEAR ( length, 16.735 , 0.001 );
162
163
}
163
164
164
165
void TestQgsMapToolIdentifyAction::perimeterCalculation ()
@@ -203,15 +204,15 @@ void TestQgsMapToolIdentifyAction::perimeterCalculation()
203
204
QCOMPARE ( result.length (), 1 );
204
205
derivedPerimeter = result.at ( 0 ).mDerivedAttributes [tr ( " Perimeter" )];
205
206
perimeter = derivedPerimeter.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
206
- QVERIFY ( qgsDoubleNear ( perimeter, 420896.0 , 0.1 ) );
207
+ QGSCOMPARENEAR ( perimeter, 420896.0 , 0.1 );
207
208
208
209
// test unchecked "keep base units" setting
209
210
s.setValue ( QStringLiteral ( " /qgis/measure/keepbaseunit" ), false );
210
211
result = action->identify ( mapPoint.x (), mapPoint.y (), QList<QgsMapLayer *>() << tempLayer.get () );
211
212
QCOMPARE ( result.length (), 1 );
212
213
derivedPerimeter = result.at ( 0 ).mDerivedAttributes [tr ( " Perimeter" )];
213
214
perimeter = derivedPerimeter.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
214
- QVERIFY ( qgsDoubleNear ( perimeter, 79.715 , 0.001 ) );
215
+ QGSCOMPARENEAR ( perimeter, 79.715 , 0.001 );
215
216
}
216
217
217
218
void TestQgsMapToolIdentifyAction::areaCalculation ()
@@ -249,15 +250,15 @@ void TestQgsMapToolIdentifyAction::areaCalculation()
249
250
QCOMPARE ( result.length (), 1 );
250
251
QString derivedArea = result.at ( 0 ).mDerivedAttributes [tr ( " Area" )];
251
252
double area = derivedArea.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
252
- QVERIFY ( qgsDoubleNear ( area, 1009089817.0 , 1.0 ) );
253
+ QGSCOMPARENEAR ( area, 1009089817.0 , 1.0 );
253
254
254
255
// check that project units are respected
255
256
QgsProject::instance ()->setAreaUnits ( QgsUnitTypes::AreaSquareMiles );
256
257
result = action->identify ( mapPoint.x (), mapPoint.y (), QList<QgsMapLayer *>() << tempLayer.get () );
257
258
QCOMPARE ( result.length (), 1 );
258
259
derivedArea = result.at ( 0 ).mDerivedAttributes [tr ( " Area" )];
259
260
area = derivedArea.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
260
- QVERIFY ( qgsDoubleNear ( area, 389.6117 , 0.001 ) );
261
+ QGSCOMPARENEAR ( area, 389.6117 , 0.001 );
261
262
262
263
// test unchecked "keep base units" setting
263
264
s.setValue ( QStringLiteral ( " /qgis/measure/keepbaseunit" ), false );
@@ -266,7 +267,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation()
266
267
QCOMPARE ( result.length (), 1 );
267
268
derivedArea = result.at ( 0 ).mDerivedAttributes [tr ( " Area" )];
268
269
area = derivedArea.remove ( ' ,' ).split ( ' ' ).at ( 0 ).toDouble ();
269
- QVERIFY ( qgsDoubleNear ( area, 389.6117 , 0.001 ) );
270
+ QGSCOMPARENEAR ( area, 389.6117 , 0.001 );
270
271
}
271
272
272
273
// private
0 commit comments