From fa549b380a473c378c422235e615553be12c5085 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 23 Mar 2017 14:58:39 +0000 Subject: [PATCH] GeoJSON IO test - ensure geometries round-trip. --- test/unit/datasource/geojson.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 3ce44506c..88e89c24e 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -29,9 +29,10 @@ #include #include #include // from_geojson +#include #include #include - +#include #include /* @@ -128,10 +129,19 @@ TEST_CASE("geojson") { "{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }" }; - for (auto const& json : valid_empty_geometries) + for (auto const& in : valid_empty_geometries) { + std::string json(in); mapnik::geometry::geometry geom; CHECK(mapnik::json::from_geojson(json, geom)); + // round trip + std::string json_out; + CHECK(mapnik::util::to_geojson(json_out, geom)); + json.erase(std::remove_if( + std::begin(json), std::end(json), + [l = std::locale{}](auto ch) { return std::isspace(ch, l); } + ), std::end(json)); + REQUIRE(json == json_out); } auto invalid_empty_geometries =