Skip to content

Commit d019900

Browse files
committedDec 28, 2015
Unit tests
1 parent bf3fbec commit d019900

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
 

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,14 +1612,12 @@ void TestQgsGeometry::lineStringV2()
16121612
QCOMPARE( l26.numPoints(), 2 );
16131613
QCOMPARE( l26.pointN( 0 ), QgsPointV2( QgsWKBTypes::PointZM, 1, 2, 2, 3 ) );
16141614
QCOMPARE( l26.pointN( 1 ), QgsPointV2( QgsWKBTypes::PointZM, 21, 22, 6, 7 ) );
1615-
QVERIFY( l26.deleteVertex( QgsVertexId( 0, 0, 0 ) ) );
1616-
QCOMPARE( l26.numPoints(), 1 );
1617-
QCOMPARE( l26.pointN( 0 ), QgsPointV2( QgsWKBTypes::PointZM, 21, 22, 6, 7 ) );
1615+
//removing the second to last vertex removes both remaining vertices
16181616
QVERIFY( l26.deleteVertex( QgsVertexId( 0, 0, 0 ) ) );
16191617
QCOMPARE( l26.numPoints(), 0 );
1618+
QVERIFY( !l26.deleteVertex( QgsVertexId( 0, 0, 0 ) ) );
16201619
QVERIFY( l26.isEmpty() );
16211620

1622-
16231621
//reversed
16241622
QgsLineStringV2 l27;
16251623
QScopedPointer< QgsLineStringV2 > reversed( l27.reversed() );
@@ -2090,6 +2088,12 @@ void TestQgsGeometry::lineStringV2()
20902088
QVERIFY( qgsDoubleNear( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 2.35619, 0.00001 ) );
20912089
QVERIFY( qgsDoubleNear( l38.vertexAngle( QgsVertexId( 0, 0, 6 ) ), 2.35619, 0.00001 ) );
20922090

2091+
//removing the second to last vertex should remove the whole line
2092+
QgsLineStringV2 l39;
2093+
l39.setPoints( QList<QgsPointV2>() << QgsPointV2( 0, 0 ) << QgsPointV2( 1, 1 ) );
2094+
QVERIFY( l39.numPoints() == 2 );
2095+
l39.deleteVertex( QgsVertexId( 0, 0, 1 ) );
2096+
QVERIFY( l39.numPoints() == 0 );
20932097
}
20942098

20952099
void TestQgsGeometry::polygonV2()
@@ -2787,6 +2791,14 @@ void TestQgsGeometry::polygonV2()
27872791
expectedGML3prec3 += QString( "<interior xmlns=\"gml\"><LinearRing xmlns=\"gml\"><coordinates xmlns=\"gml\">0.667,0.667 0.667,1.333 1.333,1.333 1.333,0.667 0.667,0.667</coordinates></LinearRing></interior></Polygon>" );
27882792
QCOMPARE( elemToString( exportPolygonFloat.asGML3( doc, 3 ) ), expectedGML3prec3 );
27892793

2794+
//removing the fourth to last vertex removes the whole ring
2795+
QgsPolygonV2 p20;
2796+
QgsLineStringV2* p20ExteriorRing = new QgsLineStringV2();
2797+
p20ExteriorRing->setPoints( QList<QgsPointV2>() << QgsPointV2( 0, 0 ) << QgsPointV2( 1, 0 ) << QgsPointV2( 1, 1 ) << QgsPointV2( 0, 0 ) );
2798+
p20.setExteriorRing( p20ExteriorRing );
2799+
QVERIFY( p20.exteriorRing() );
2800+
p20.deleteVertex( QgsVertexId( 0, 0, 2 ) );
2801+
QVERIFY( !p20.exteriorRing() );
27902802
}
27912803

27922804
void TestQgsGeometry::fromQgsPoint()

0 commit comments

Comments
 (0)
Please sign in to comment.