Skip to content
Permalink
Browse files

add tests

  • Loading branch information
lbartoletti authored and nyalldawson committed Apr 8, 2019
1 parent a9cec38 commit 2c53c1d34ed99aeb96d2805a789dd85b38bfd271
Showing with 33 additions and 0 deletions.
  1. +33 −0 tests/src/core/testqgsgeometry.cpp
@@ -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 );
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.
You can’t perform that action at this time.