Skip to content

Commit e4dab7c

Browse files
committed
Fix intermittently failing QgsGeometry asGML tests
1 parent 43536a6 commit e4dab7c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/core/qgstestutils.h

+5
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,9 @@
5555
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
5656
}
5757

58+
//sometimes GML attributes are in a different order - but that's ok
59+
#define QGSCOMPAREGML(result,expected) { \
60+
QCOMPARE( result.replace( QStringLiteral("ts=\" \" cs=\",\""), QStringLiteral("cs=\",\" ts=\" \"") ), expected ); \
61+
}
62+
5863
#endif // QGSTESTUTILS_H

tests/src/core/testqgsgeometry.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ void TestQgsGeometry::point()
617617
QgsPoint exportPointFloat( 1 / 3.0, 2 / 3.0 );
618618
QDomDocument doc( QStringLiteral( "gml" ) );
619619
QString expectedGML2( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,2</coordinates></Point>" ) );
620-
QCOMPARE( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
620+
QGSCOMPAREGML( elemToString( exportPoint.asGML2( doc ) ), expectedGML2 );
621621
QString expectedGML2prec3( QStringLiteral( "<Point xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667</coordinates></Point>" ) );
622-
QCOMPARE( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
622+
QGSCOMPAREGML( elemToString( exportPointFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
623623

624624
//asGML3
625625
QString expectedGML3( QStringLiteral( "<Point xmlns=\"gml\"><pos xmlns=\"gml\" srsDimension=\"2\">1 2</pos></Point>" ) );
@@ -1739,9 +1739,9 @@ void TestQgsGeometry::lineString()
17391739
<< QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) );
17401740
QDomDocument doc( QStringLiteral( "gml" ) );
17411741
QString expectedGML2( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">31,32 41,42 51,52</coordinates></LineString>" ) );
1742-
QCOMPARE( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
1742+
QGSCOMPAREGML( elemToString( exportLine.asGML2( doc ) ), expectedGML2 );
17431743
QString expectedGML2prec3( QStringLiteral( "<LineString xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.333,0.667 1.333,1.667 2.333,2.667</coordinates></LineString>" ) );
1744-
QCOMPARE( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
1744+
QGSCOMPAREGML( elemToString( exportLineFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
17451745

17461746
//asGML3
17471747
QString expectedGML3( QStringLiteral( "<LineString xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">31 32 41 42 51 52</posList></LineString>" ) );
@@ -3203,7 +3203,7 @@ void TestQgsGeometry::polygon()
32033203

32043204
// as GML2
32053205
QString expectedSimpleGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>" ) );
3206-
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );
3206+
QGSCOMPAREGML( elemToString( exportPolygon.asGML2( doc ) ), expectedSimpleGML2 );
32073207

32083208
//as GML3
32093209
QString expectedSimpleGML3( QStringLiteral( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior></Polygon>" ) );
@@ -3240,10 +3240,10 @@ void TestQgsGeometry::polygon()
32403240
// as GML2
32413241
QString expectedGML2( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0,0 0,10 10,10 10,0 0,0</coordinates></LinearRing></outerBoundaryIs>" ) );
32423242
expectedGML2 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1,1 1,9 9,9 9,1 1,1</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3243-
QCOMPARE( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
3243+
QGSCOMPAREGML( elemToString( exportPolygon.asGML2( doc ) ), expectedGML2 );
32443244
QString expectedGML2prec3( QStringLiteral( "<Polygon xmlns=\"gml\"><outerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">1.111,1.111 1.111,11.111 11.111,11.111 11.111,1.111 1.111,1.111</coordinates></LinearRing></outerBoundaryIs>" ) );
32453245
expectedGML2prec3 += QStringLiteral( "<innerBoundaryIs xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\" cs=\",\" ts=\" \">0.667,0.667 0.667,1.333 1.333,1.333 1.333,0.667 0.667,0.667</coordinates></LinearRing></innerBoundaryIs></Polygon>" );
3246-
QCOMPARE( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
3246+
QGSCOMPAREGML( elemToString( exportPolygonFloat.asGML2( doc, 3 ) ), expectedGML2prec3 );
32473247

32483248
//as GML3
32493249
QString expectedGML3( QStringLiteral( "<Polygon xmlns=\"gml\"><exterior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">0 0 0 10 10 10 10 0 0 0</posList></LinearRing></exterior>" ) );

0 commit comments

Comments
 (0)