Skip to content

Commit

Permalink
100% test coverage for QgsFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 11, 2015
1 parent 87168c1 commit bb339f7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/src/core/testqgsfeature.cpp
Expand Up @@ -431,7 +431,7 @@ void TestQgsFeature::dataStream()
QCOMPARE( *resultFeature.constGeometry()->asWkb(), *originalFeature.constGeometry()->asWkb() );
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );

//also test with feature without geometry
//also test with feature empty geometry
originalFeature.setGeometry( new QgsGeometry() );
QByteArray ba2;
QDataStream ds2( &ba2, QIODevice::ReadWrite );
Expand All @@ -444,6 +444,20 @@ void TestQgsFeature::dataStream()
QCOMPARE( resultFeature.attributes(), originalFeature.attributes() );
QVERIFY( resultFeature.constGeometry()->isEmpty() );
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );

//test with feature with null geometry
originalFeature.setGeometry( 0 );
QByteArray ba3;
QDataStream ds3( &ba3, QIODevice::ReadWrite );
ds3 << originalFeature;

ds3.device()->seek( 0 );
ds3 >> resultFeature;

QCOMPARE( resultFeature.id(), originalFeature.id() );
QCOMPARE( resultFeature.attributes(), originalFeature.attributes() );
QVERIFY( resultFeature.constGeometry()->isEmpty() );
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );
}

QTEST_MAIN( TestQgsFeature )
Expand Down

0 comments on commit bb339f7

Please sign in to comment.