Skip to content

Commit

Permalink
Fix some possible leaks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 31, 2017
1 parent 6bddc38 commit e68835f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -4592,8 +4592,8 @@ void TestQgsGeometry::multiPolygon()
polygon1.setExteriorRing( ring1.clone() );
multiPolygon1.addGeometry( polygon1.clone() );

QgsAbstractGeometry *boundary = multiPolygon1.boundary();
QgsMultiLineString *lineBoundary = dynamic_cast< QgsMultiLineString * >( boundary );
std::unique_ptr< QgsAbstractGeometry > boundary( multiPolygon1.boundary() );
QgsMultiLineString *lineBoundary = dynamic_cast< QgsMultiLineString * >( boundary.get() );
QVERIFY( lineBoundary );
QCOMPARE( lineBoundary->numGeometries(), 1 );
QCOMPARE( dynamic_cast< QgsLineString * >( lineBoundary->geometryN( 0 ) )->numPoints(), 4 );
Expand All @@ -4605,7 +4605,6 @@ void TestQgsGeometry::multiPolygon()
QCOMPARE( dynamic_cast< QgsLineString * >( lineBoundary->geometryN( 0 ) )->yAt( 1 ), 0.0 );
QCOMPARE( dynamic_cast< QgsLineString * >( lineBoundary->geometryN( 0 ) )->yAt( 2 ), 1.0 );
QCOMPARE( dynamic_cast< QgsLineString * >( lineBoundary->geometryN( 0 ) )->yAt( 3 ), 0.0 );
delete boundary;

// add polygon with interior rings
QgsLineString ring2;
Expand All @@ -4619,8 +4618,8 @@ void TestQgsGeometry::multiPolygon()
polygon2.setInteriorRings( QList< QgsCurve * >() << boundaryRing1.clone() << boundaryRing2.clone() );
multiPolygon1.addGeometry( polygon2.clone() );

boundary = multiPolygon1.boundary();
QgsMultiLineString *multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary );
boundary.reset( multiPolygon1.boundary() );
QgsMultiLineString *multiLineBoundary( static_cast< QgsMultiLineString * >( boundary.get() ) );
QVERIFY( multiLineBoundary );
QCOMPARE( multiLineBoundary->numGeometries(), 4 );
QCOMPARE( dynamic_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->numPoints(), 4 );
Expand Down Expand Up @@ -4659,7 +4658,6 @@ void TestQgsGeometry::multiPolygon()
QCOMPARE( dynamic_cast< QgsLineString * >( multiLineBoundary->geometryN( 3 ) )->yAt( 1 ), 10.8 );
QCOMPARE( dynamic_cast< QgsLineString * >( multiLineBoundary->geometryN( 3 ) )->yAt( 2 ), 10.9 );
QCOMPARE( dynamic_cast< QgsLineString * >( multiLineBoundary->geometryN( 3 ) )->yAt( 3 ), 10.8 );
delete boundary;
}

void TestQgsGeometry::geometryCollection()
Expand Down

0 comments on commit e68835f

Please sign in to comment.