Skip to content
Permalink
Browse files

testqgsgml.cpp: fix memory leaks in test

  • Loading branch information
rouault committed Jun 10, 2016
1 parent 544e8bd commit 5acb1288671286be41ac042c46fff48c829a8915
Showing with 27 additions and 1 deletion.
  1. +27 −1 tests/src/core/testqgsgml.cpp
@@ -106,9 +106,11 @@ void TestQgsGML::testFromURL()
tmpFile.flush();
QCOMPARE( gmlParser.getFeatures( QUrl::fromLocalFile( tmpFile.fileName() ).toString(), &wkbType ), 0 );
QCOMPARE( wkbType, QGis::WKBPoint );
QCOMPARE( gmlParser.featuresMap().size(), 1 );
QMap<QgsFeatureId, QgsFeature* > featureMaps = gmlParser.featuresMap();
QCOMPARE( featureMaps.size(), 1 );
QCOMPARE( gmlParser.idsMap().size(), 1 );
QCOMPARE( gmlParser.crs().authid(), QString( "EPSG:27700" ) );
delete featureMaps[ 0 ];
}

void TestQgsGML::testFromByteArray()
@@ -125,6 +127,7 @@ void TestQgsGML::testFromByteArray()
QMap<QgsFeatureId, QString > idsMap = gmlParser.idsMap();
QVERIFY( idsMap.constFind( 0 ) != idsMap.constEnd() );
QCOMPARE( idsMap[ 0 ], QString( "mytypename.1" ) );
delete featureMaps[ 0 ];
}

void TestQgsGML::testStreamingParser()
@@ -155,6 +158,7 @@ void TestQgsGML::testStreamingParser()
QCOMPARE( gmlParser.getAndStealReadyFeatures().size(), 0 );
QCOMPARE( gmlParser.getEPSGCode(), 27700 );
QCOMPARE( gmlParser.wkbType(), QGis::WKBPoint );
delete features[0].first;
}

void TestQgsGML::testStreamingParserInvalidGML()
@@ -188,6 +192,7 @@ void TestQgsGML::testPointGML2()
QVERIFY( features[0].first->constGeometry() != nullptr );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 10, 20 ) );
delete features[0].first;
}

void TestQgsGML::testLineStringGML2()
@@ -216,6 +221,7 @@ void TestQgsGML::testLineStringGML2()
QCOMPARE( line.size(), 2 );
QCOMPARE( line[0], QgsPoint( 10, 20 ) );
QCOMPARE( line[1], QgsPoint( 30, 40 ) );
delete features[0].first;
}

void TestQgsGML::testPolygonGML2()
@@ -253,6 +259,7 @@ void TestQgsGML::testPolygonGML2()
QCOMPARE( poly.size(), 2 );
QCOMPARE( poly[0].size(), 5 );
QCOMPARE( poly[1].size(), 4 );
delete features[0].first;
}

void TestQgsGML::testMultiPointGML2()
@@ -290,6 +297,7 @@ void TestQgsGML::testMultiPointGML2()
QCOMPARE( multi.size(), 2 );
QCOMPARE( multi[0], QgsPoint( 10, 20 ) );
QCOMPARE( multi[1], QgsPoint( 30, 40 ) );
delete features[0].first;
}

void TestQgsGML::testMultiLineStringGML2()
@@ -329,6 +337,7 @@ void TestQgsGML::testMultiLineStringGML2()
QCOMPARE( multi[0][0], QgsPoint( 10, 20 ) );
QCOMPARE( multi[0][1], QgsPoint( 30, 40 ) );
QCOMPARE( multi[1].size(), 3 );
delete features[0].first;
}

void TestQgsGML::testMultiPolygonGML2()
@@ -365,6 +374,7 @@ void TestQgsGML::testMultiPolygonGML2()
QCOMPARE( multi.size(), 1 );
QCOMPARE( multi[0].size(), 1 );
QCOMPARE( multi[0][0].size(), 5 );
delete features[0].first;
}

void TestQgsGML::testPointGML3()
@@ -392,6 +402,7 @@ void TestQgsGML::testPointGML3()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 10, 20 ) );
delete features[0].first;
}

void TestQgsGML::testPointGML3_EPSG_4326()
@@ -419,6 +430,7 @@ void TestQgsGML::testPointGML3_EPSG_4326()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 2, 49 ) );
delete features[0].first;
}

void TestQgsGML::testPointGML3_urn_EPSG_4326()
@@ -446,6 +458,7 @@ void TestQgsGML::testPointGML3_urn_EPSG_4326()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 2, 49 ) );
delete features[0].first;
}

void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG()
@@ -473,6 +486,7 @@ void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 2, 49 ) );
delete features[0].first;
}

void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG_invert()
@@ -500,6 +514,7 @@ void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG_invert()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 2, 49 ) );
delete features[0].first;
}

void TestQgsGML::testLineStringGML3()
@@ -528,6 +543,7 @@ void TestQgsGML::testLineStringGML3()
QCOMPARE( line.size(), 2 );
QCOMPARE( line[0], QgsPoint( 10, 20 ) );
QCOMPARE( line[1], QgsPoint( 30, 40 ) );
delete features[0].first;
}

void TestQgsGML::testLineStringGML3_LineStringSegment()
@@ -554,6 +570,7 @@ void TestQgsGML::testLineStringGML3_LineStringSegment()
QCOMPARE( line.size(), 2 );
QCOMPARE( line[0], QgsPoint( 10, 20 ) );
QCOMPARE( line[1], QgsPoint( 30, 40 ) );
delete features[0].first;
}

void TestQgsGML::testPolygonGML3()
@@ -591,6 +608,7 @@ void TestQgsGML::testPolygonGML3()
QCOMPARE( poly.size(), 2 );
QCOMPARE( poly[0].size(), 5 );
QCOMPARE( poly[1].size(), 4 );
delete features[0].first;
}

void TestQgsGML::testPolygonGML3_srsDimension_on_Polygon()
@@ -622,6 +640,7 @@ void TestQgsGML::testPolygonGML3_srsDimension_on_Polygon()
QgsPolygon poly = features[0].first->constGeometry()->asPolygon();
QCOMPARE( poly.size(), 1 );
QCOMPARE( poly[0].size(), 5 );
delete features[0].first;
}

void TestQgsGML::testMultiLineStringGML3()
@@ -661,6 +680,7 @@ void TestQgsGML::testMultiLineStringGML3()
QCOMPARE( multi[0][0], QgsPoint( 10, 20 ) );
QCOMPARE( multi[0][1], QgsPoint( 30, 40 ) );
QCOMPARE( multi[1].size(), 3 );
delete features[0].first;
}

void TestQgsGML::testMultiPolygonGML3()
@@ -706,6 +726,7 @@ void TestQgsGML::testMultiPolygonGML3()
QCOMPARE( multi.size(), 2 );
QCOMPARE( multi[0].size(), 1 );
QCOMPARE( multi[0][0].size(), 5 );
delete features[0].first;
}

void TestQgsGML::testPointGML3_2()
@@ -734,6 +755,7 @@ void TestQgsGML::testPointGML3_2()
QCOMPARE( features[0].second, QString( "mytypename.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 10, 20 ) );
delete features[0].first;
}

void TestQgsGML::testBoundingBoxGML2()
@@ -761,6 +783,7 @@ void TestQgsGML::testBoundingBoxGML2()
QgsPolygon poly = features[0].first->constGeometry()->asPolygon();
QCOMPARE( poly.size(), 1 );
QCOMPARE( poly[0].size(), 5 );
delete features[0].first;
}

void TestQgsGML::testBoundingBoxGML3()
@@ -789,6 +812,7 @@ void TestQgsGML::testBoundingBoxGML3()
QgsPolygon poly = features[0].first->constGeometry()->asPolygon();
QCOMPARE( poly.size(), 1 );
QCOMPARE( poly[0].size(), 5 );
delete features[0].first;
}

void TestQgsGML::testNumberMatchedNumberReturned()
@@ -930,6 +954,7 @@ void TestQgsGML::testTuple()
QCOMPARE( features[0].second, QString( "firstlayer.1|secondlayer.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 10, 20 ) );
delete features[0].first;
}

void TestQgsGML::testRenamedFields()
@@ -969,6 +994,7 @@ void TestQgsGML::testRenamedFields()
QCOMPARE( features[0].second, QString( "mylayer.1" ) );
QCOMPARE( features[0].first->constGeometry()->wkbType(), QGis::WKBPoint );
QCOMPARE( features[0].first->constGeometry()->asPoint(), QgsPoint( 10, 20 ) );
delete features[0].first;
}

void TestQgsGML::testTruncatedResponse()

0 comments on commit 5acb128

Please sign in to comment.
You can’t perform that action at this time.