add "invalid" empty geometry tests

This commit is contained in:
artemp 2017-03-22 15:07:07 +00:00
parent 7caa0cffd4
commit 60d891f094

View file

@ -121,11 +121,11 @@ TEST_CASE("geojson") {
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\": [[ []] ] }}"
"{ \"type\": \"LineString\", \"coordinates\": [] }",
"{ \"type\": \"Polygon\", \"coordinates\": [ [ ] ] } ",
"{ \"type\": \"MultiPoint\", \"coordinates\": [ ] }",
"{ \"type\": \"MultiLineString\", \"coordinates\": [ [] ] }",
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }"
};
for (auto const& json : valid_empty_geometries)
@ -133,6 +133,22 @@ TEST_CASE("geojson") {
mapnik::geometry::geometry<double> geom;
CHECK(mapnik::json::from_geojson(json, geom));
}
auto invalid_empty_geometries =
{
"{ \"type\": \"Point\", \"coordinates\": [] }",
"{ \"type\": \"LineString\", \"coordinates\": [[]] }"
"{ \"type\": \"Polygon\", \"coordinates\": [[[]]] }",
"{ \"type\": \"MultiPoint\", \"coordinates\": [[]] }",
"{ \"type\": \"MultiLineString\", \"coordinates\": [[[]]] }",
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[[[]]]] }"
};
for (auto const& json : invalid_empty_geometries)
{
mapnik::geometry::geometry<double> geom;
CHECK(!mapnik::json::from_geojson(json, geom));
}
}
SECTION("GeoJSON num_features_to_query")