@@ -215,6 +215,31 @@ void TestQgisAppClipboard::pasteWkt()
215
215
point = dynamic_cast < QgsPointV2* >( features.at ( 1 ).constGeometry ()->geometry () );
216
216
QCOMPARE ( point->x (), 111.0 );
217
217
QCOMPARE ( point->y (), 30.0 );
218
+
219
+ // be sure parsing does not consider attached parameters that
220
+ // can change geometryType as in https://issues.qgis.org/issues/16870
221
+ mQgisApp ->clipboard ()->setText ( QStringLiteral ( " POINT (111 30)\t GoodFieldValue\n POINT (125 10)\t (WrongFieldValue)" ) );
222
+
223
+ features = mQgisApp ->clipboard ()->copyOf ();
224
+ QCOMPARE ( features.length (), 2 );
225
+
226
+ QVERIFY ( features.at ( 0 ).constGeometry () && !features.at ( 0 ).constGeometry ()->isEmpty () );
227
+ QCOMPARE ( features.at ( 0 ).constGeometry ()->geometry ()->wkbType (), QgsWKBTypes::Point );
228
+ const QgsGeometry *featureGeom = features.at ( 0 ).constGeometry ();
229
+ point = dynamic_cast < QgsPointV2 * >( featureGeom->geometry () );
230
+ QCOMPARE ( point->x (), 111.0 );
231
+ QCOMPARE ( point->y (), 30.0 );
232
+
233
+ QVERIFY ( features.at ( 1 ).constGeometry () && !features.at ( 1 ).constGeometry ()->isEmpty () );
234
+ QCOMPARE ( features.at ( 1 ).constGeometry ()->geometry ()->wkbType (), QgsWKBTypes::Point );
235
+ point = dynamic_cast < QgsPointV2 * >( features.at ( 1 ).constGeometry ()->geometry () );
236
+ QCOMPARE ( point->x (), 125.0 );
237
+ QCOMPARE ( point->y (), 10.0 );
238
+
239
+ // only fields => no geom so no feature list is returned
240
+ mQgisApp ->clipboard ()->setText ( QStringLiteral ( " MNL\t 11\t 282\t km\t\n MNL\t 11\t 347.80000000000001\t km\t " ) );
241
+ features = mQgisApp ->clipboard ()->copyOf ();
242
+ QCOMPARE ( features.length (), 0 );
218
243
}
219
244
220
245
void TestQgisAppClipboard::pasteGeoJson ()
0 commit comments