@@ -158,6 +158,8 @@ class TestQgsGeometry : public QObject
158
158
159
159
void convertGeometryCollectionToSubclass();
160
160
161
+ void emptyJson();
162
+
161
163
private:
162
164
//! A helper method to do a render check to see if the geometry op is as expected
163
165
bool renderCheck( const QString &testName, const QString &comment = QString(), int mismatchCount = 0 );
@@ -17469,5 +17471,36 @@ void TestQgsGeometry::convertGeometryCollectionToSubclass()
17469
17471
QVERIFY( !wrong.convertGeometryCollectionToSubclass( QgsWkbTypes::PolygonGeometry ) );
17470
17472
}
17471
17473
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
+
17472
17505
QGSTEST_MAIN( TestQgsGeometry )
17473
17506
#include "testqgsgeometry.moc"
0 commit comments