Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti authored and nyalldawson committed Apr 8, 2019
1 parent a9cec38 commit 2c53c1d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -156,6 +156,8 @@ class TestQgsGeometry : public QObject

void convertGeometryCollectionToSubclass();

void emptyJson();

private:
//! A helper method to do a render check to see if the geometry op is as expected
bool renderCheck( const QString &testName, const QString &comment = QString(), int mismatchCount = 0 );
Expand Down Expand Up @@ -17244,5 +17246,36 @@ void TestQgsGeometry::convertGeometryCollectionToSubclass()
QVERIFY( !wrong.convertGeometryCollectionToSubclass( QgsWkbTypes::PolygonGeometry ) );
}

void TestQgsGeometry::emptyJson()
{
QString expected;
// TODO: harmonize Json output. Should be ... [] }
expected = QStringLiteral( "{\"type\": \"LineString\", \"coordinates\": [ ]}" );
QCOMPARE( QgsCircularString().asJson(), expected );
QCOMPARE( QgsCompoundCurve().asJson(), expected );
QCOMPARE( QgsLineString().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"GeometryCollection\", \"geometries\": [] }" );
QCOMPARE( QgsGeometryCollection().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"MultiLineString\", \"coordinates\": [] }" );
QCOMPARE( QgsMultiCurve().asJson(), expected );
QCOMPARE( QgsMultiLineString().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"MultiPoint\", \"coordinates\": [ ] }" );
QCOMPARE( QgsMultiPoint().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"MultiPolygon\", \"coordinates\": [] }" );
QCOMPARE( QgsMultiSurface().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"Point\", \"coordinates\": [0, 0]}" ); // should be []
QCOMPARE( QgsPoint().asJson(), expected );

expected = QStringLiteral( "{\"type\": \"Polygon\", \"coordinates\": [] }" );
QCOMPARE( QgsCurvePolygon().asJson(), expected );
QCOMPARE( QgsPolygon().asJson(), expected );
QCOMPARE( QgsTriangle().asJson(), expected );
}

QGSTEST_MAIN( TestQgsGeometry )
#include "testqgsgeometry.moc"

0 comments on commit 2c53c1d

Please sign in to comment.