Skip to content

Commit

Permalink
test geojson - add empty featurecollection test
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Aug 15, 2016
1 parent 31814b3 commit 008a6eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/data
23 changes: 19 additions & 4 deletions test/unit/datasource/geojson.cpp
Expand Up @@ -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})
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<double>(123,456,123,456));
Expand Down Expand Up @@ -693,7 +709,6 @@ TEST_CASE("geojson") {
REQUIRE_FIELD_NAMES(fields, names);

auto fs = all_features(ds);
REQUIRE(bool(fs));
std::initializer_list<attr> attrs = {
attr{"name", tr.transcode("Test")},
attr{"NOM_FR", tr.transcode("Québec")},
Expand Down

0 comments on commit 008a6eb

Please sign in to comment.