Skip to content
Permalink
Browse files
Add test for unhandled encoding
  • Loading branch information
troopa81 committed Aug 19, 2021
1 parent 2f6cd43 commit 2966ef96e42d2156300bd07d54a3434e2137f6e7
Showing with 33 additions and 0 deletions.
  1. +33 −0 tests/src/core/testqgsgml.cpp
@@ -85,6 +85,7 @@ class TestQgsGML : public QObject
void testSameTypeameAsGeomName();
void testUnknownEncoding_data();
void testUnknownEncoding();
void testUnhandledEncoding();
};

const QString data1( "<myns:FeatureCollection "
@@ -1343,5 +1344,37 @@ void TestQgsGML::testUnknownEncoding()
}
}

void TestQgsGML::testUnhandledEncoding()
{
QgsWkbTypes::Type wkbType;

QString data = QStringLiteral(
"<?xml version='1.0' encoding='my-unexisting-encoding'?>"
"<myns:FeatureCollection "
"xmlns:myns='http://myns' "
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
"xmlns:gml='http://www.opengis.net/gml'>"
"<gml:boundedBy><gml:null>unknown</gml:null></gml:boundedBy>"
"<gml:featureMember>"
"<myns:mytypename fid='mytypename.1'>"
"<myns:strfield>price: 10€</myns:strfield>"
"<myns:mygeom>"
"<gml:Point srsName='http://www.opengis.net/gml/srs/epsg.xml#27700'>"
"<gml:coordinates decimal='.' cs=',' ts=' '>10,20</gml:coordinates>"
"</gml:Point>"
"</myns:mygeom>"
"</myns:mytypename>"
"</gml:featureMember>"
"</myns:FeatureCollection>" );

QgsFields fields;
fields.append( QgsField( QStringLiteral( "strfield" ), QVariant::String, QStringLiteral( "string" ) ) );

QgsGml gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields );
QCOMPARE( gmlParser.getFeatures( data.toUtf8(), &wkbType ), 0 );
QMap<QgsFeatureId, QgsFeature * > featureMaps = gmlParser.featuresMap();
QCOMPARE( featureMaps.size(), 0 );
}

QGSTEST_MAIN( TestQgsGML )
#include "testqgsgml.moc"

0 comments on commit 2966ef9

Please sign in to comment.