diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 337f8098b..6189fe19e 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -28,6 +28,7 @@ #include #include #include +#include // from_geojson #include #include @@ -115,6 +116,25 @@ TEST_CASE("geojson") { } } + SECTION("GeoJSON empty Geometries handling") + { + auto valid_empty_geometries = + { + "null", // Point can't be empty + "{ \"type\": \"LineString\", \"coordinates\": [] }}", + "{ \"type\": \"Polygon\", \"coordinates\": [ [ ] ] } }", + "{ \"type\": \"MultiPoint\", \"coordinates\": [ ] }}", + "{ \"type\": \"MultiLineString\", \"coordinates\": [ [] ] }}", + "{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }}" + }; + + for (auto const& json : valid_empty_geometries) + { + mapnik::geometry::geometry geom; + CHECK(mapnik::json::from_geojson(json, geom)); + } + } + SECTION("GeoJSON num_features_to_query") { std::string filename = "./test/data/json/featurecollection-multipleprops.geojson"; @@ -557,8 +577,7 @@ TEST_CASE("geojson") { { mapnik::parameters params; params["type"] = "geojson"; - for (auto const& c_str : {"./test/data/json/featurecollection-malformed.json", - "./test/data/json/featurecollection-malformed-2.json"}) + for (auto const& c_str : {"./test/data/json/featurecollection-malformed.json"}) { std::string filename(c_str); params["file"] = filename;