Skip to content

Commit

Permalink
testqgsgml.cpp: fix memory leaks in test
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jun 10, 2016
1 parent 544e8bd commit 5acb128
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/src/core/testqgsgml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5acb128

Please sign in to comment.