Skip to content

Commit 59c00b8

Browse files
lbartolettinyalldawson
authored andcommitted
add tests
1 parent e3d0005 commit 59c00b8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/src/core/testqgsgeometry.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class TestQgsGeometry : public QObject
158158

159159
void convertGeometryCollectionToSubclass();
160160

161+
void emptyJson();
162+
161163
private:
162164
//! A helper method to do a render check to see if the geometry op is as expected
163165
bool renderCheck( const QString &testName, const QString &comment = QString(), int mismatchCount = 0 );
@@ -17469,5 +17471,36 @@ void TestQgsGeometry::convertGeometryCollectionToSubclass()
1746917471
QVERIFY( !wrong.convertGeometryCollectionToSubclass( QgsWkbTypes::PolygonGeometry ) );
1747017472
}
1747117473

17474+
void TestQgsGeometry::emptyJson()
17475+
{
17476+
QString expected;
17477+
// TODO: harmonize Json output. Should be ... [] }
17478+
expected = QStringLiteral( "{\"type\": \"LineString\", \"coordinates\": [ ]}" );
17479+
QCOMPARE( QgsCircularString().asJson(), expected );
17480+
QCOMPARE( QgsCompoundCurve().asJson(), expected );
17481+
QCOMPARE( QgsLineString().asJson(), expected );
17482+
17483+
expected = QStringLiteral( "{\"type\": \"GeometryCollection\", \"geometries\": [] }" );
17484+
QCOMPARE( QgsGeometryCollection().asJson(), expected );
17485+
17486+
expected = QStringLiteral( "{\"type\": \"MultiLineString\", \"coordinates\": [] }" );
17487+
QCOMPARE( QgsMultiCurve().asJson(), expected );
17488+
QCOMPARE( QgsMultiLineString().asJson(), expected );
17489+
17490+
expected = QStringLiteral( "{\"type\": \"MultiPoint\", \"coordinates\": [ ] }" );
17491+
QCOMPARE( QgsMultiPoint().asJson(), expected );
17492+
17493+
expected = QStringLiteral( "{\"type\": \"MultiPolygon\", \"coordinates\": [] }" );
17494+
QCOMPARE( QgsMultiSurface().asJson(), expected );
17495+
17496+
expected = QStringLiteral( "{\"type\": \"Point\", \"coordinates\": [0, 0]}" ); // should be []
17497+
QCOMPARE( QgsPoint().asJson(), expected );
17498+
17499+
expected = QStringLiteral( "{\"type\": \"Polygon\", \"coordinates\": [] }" );
17500+
QCOMPARE( QgsCurvePolygon().asJson(), expected );
17501+
QCOMPARE( QgsPolygon().asJson(), expected );
17502+
QCOMPARE( QgsTriangle().asJson(), expected );
17503+
}
17504+
1747217505
QGSTEST_MAIN( TestQgsGeometry )
1747317506
#include "testqgsgeometry.moc"

0 commit comments

Comments
 (0)