Skip to content

Commit bb339f7

Browse files
committedNov 11, 2015
100% test coverage for QgsFeature
1 parent 87168c1 commit bb339f7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed
 

‎tests/src/core/testqgsfeature.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void TestQgsFeature::dataStream()
431431
QCOMPARE( *resultFeature.constGeometry()->asWkb(), *originalFeature.constGeometry()->asWkb() );
432432
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );
433433

434-
//also test with feature without geometry
434+
//also test with feature empty geometry
435435
originalFeature.setGeometry( new QgsGeometry() );
436436
QByteArray ba2;
437437
QDataStream ds2( &ba2, QIODevice::ReadWrite );
@@ -444,6 +444,20 @@ void TestQgsFeature::dataStream()
444444
QCOMPARE( resultFeature.attributes(), originalFeature.attributes() );
445445
QVERIFY( resultFeature.constGeometry()->isEmpty() );
446446
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );
447+
448+
//test with feature with null geometry
449+
originalFeature.setGeometry( 0 );
450+
QByteArray ba3;
451+
QDataStream ds3( &ba3, QIODevice::ReadWrite );
452+
ds3 << originalFeature;
453+
454+
ds3.device()->seek( 0 );
455+
ds3 >> resultFeature;
456+
457+
QCOMPARE( resultFeature.id(), originalFeature.id() );
458+
QCOMPARE( resultFeature.attributes(), originalFeature.attributes() );
459+
QVERIFY( resultFeature.constGeometry()->isEmpty() );
460+
QCOMPARE( resultFeature.isValid(), originalFeature.isValid() );
447461
}
448462

449463
QTEST_MAIN( TestQgsFeature )

0 commit comments

Comments
 (0)
Please sign in to comment.