Skip to content

Commit

Permalink
Followup c6f9b07, add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 21, 2015
1 parent 7d97ab5 commit 7f31809
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/src/core/testqgsfeature.cpp
Expand Up @@ -221,6 +221,12 @@ void TestQgsFeature::geometry()
QVERIFY( ! copy.constGeometry() );
QCOMPARE( *feature.constGeometry()->asWkb(), *mGeometry.data()->asWkb() );

//test no crash when setting an empty geometry and triggering a detach
QgsFeature emptyGeomFeature;
emptyGeomFeature.setGeometry( 0 );
copy = emptyGeomFeature;
copy.setFeatureId( 5 ); //force detach

//setGeometry
//always start with a copy so that we can test implicit sharing detachment is working
copy = feature;
Expand Down Expand Up @@ -257,14 +263,14 @@ void TestQgsFeature::geometry()
QCOMPARE( *feature.constGeometry()->asWkb(), *mGeometry.data()->asWkb() );

//geometryAndOwnership
Q_NOWARN_DEPRECATED_PUSH
Q_NOWARN_DEPRECATED_PUSH
copy = feature;
QCOMPARE( *copy.constGeometry()->asWkb(), *mGeometry.data()->asWkb() );
QgsGeometry* geom1 = copy.geometryAndOwnership();
QCOMPARE( *geom1->asWkb(), *mGeometry->asWkb() );
QgsGeometry* geom2 = feature.geometryAndOwnership();
QCOMPARE( *geom2->asWkb(), *mGeometry->asWkb() );
Q_NOWARN_DEPRECATED_POP
Q_NOWARN_DEPRECATED_POP
delete geom1;
delete geom2;
}
Expand Down

0 comments on commit 7f31809

Please sign in to comment.