From 008a6eb4cfd76fc6dbc500417c6c5031c1247348 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 10:44:54 +0100 Subject: [PATCH] test geojson - add empty featurecollection test --- test/data | 2 +- test/unit/datasource/geojson.cpp | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/data b/test/data index ca5716fce..14eabf8f4 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit ca5716fcef3ed33b319d3047f7d8190bf6ed6081 +Subproject commit 14eabf8f407294e71636cddfce68297a4f4e0303 diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 60052db8b..cf3214862 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -96,6 +96,25 @@ TEST_CASE("geojson") { } } + SECTION("GeoJSON an empty FeatureCollection") + { + for (auto cache_features : {true, false}) + { + mapnik::parameters params; + params["type"] = "geojson"; + params["file"] = "./test/data/json/empty_featurecollection.json"; + params["cache_features"] = cache_features; + auto ds = mapnik::datasource_cache::instance().create(params); + CHECK(ds != nullptr); + auto fs = all_features(ds); + REQUIRE(mapnik::is_valid(fs)); + while (auto f = fs->next()) + { + CHECK(false); // shouldn't get here + } + } + } + SECTION("GeoJSON invalid Point") { for (auto cache_features : {true, false}) @@ -285,8 +304,6 @@ TEST_CASE("geojson") { } auto features = ds->features(query); auto features2 = ds->features_at_point(ds->envelope().center(),0); - REQUIRE(features != nullptr); - REQUIRE(features2 != nullptr); auto feature = features->next(); auto feature2 = features2->next(); REQUIRE(feature != nullptr); @@ -404,7 +421,6 @@ TEST_CASE("geojson") { query.add_property_name(field.get_name()); } auto features = ds->features(query); - REQUIRE(features != nullptr); auto feature = features->next(); REQUIRE(feature != nullptr); REQUIRE(feature->envelope() == mapnik::box2d(123,456,123,456)); @@ -693,7 +709,6 @@ TEST_CASE("geojson") { REQUIRE_FIELD_NAMES(fields, names); auto fs = all_features(ds); - REQUIRE(bool(fs)); std::initializer_list attrs = { attr{"name", tr.transcode("Test")}, attr{"NOM_FR", tr.transcode("Québec")},