Skip to content
Permalink
Browse files

100% test coverage for QgsFeature

  • Loading branch information
nyalldawson committed Nov 11, 2015
1 parent 87168c1 commit bb339f7a5b35d2a19c802d5ff3988a0e3f0d5558
Showing with 15 additions and 1 deletion.
  1. +15 −1 tests/src/core/testqgsfeature.cpp
@@ -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 );
@@ -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 )

0 comments on commit bb339f7

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