transcode input strings to UTF-8 (portability)
This commit is contained in:
parent
acb2d56f49
commit
37a8aed62d
2 changed files with 28 additions and 26 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "catch.hpp"
|
||||
#include "ds_test_util.hpp"
|
||||
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/datasource_cache.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
@ -657,6 +658,7 @@ TEST_CASE("geojson") {
|
|||
|
||||
SECTION("GeoJSON properties are properly expressed")
|
||||
{
|
||||
mapnik::transcoder tr("utf8");
|
||||
mapnik::parameters params;
|
||||
params["type"] = "geojson";
|
||||
|
||||
|
@ -693,21 +695,21 @@ TEST_CASE("geojson") {
|
|||
auto fs = all_features(ds);
|
||||
REQUIRE(bool(fs));
|
||||
std::initializer_list<attr> attrs = {
|
||||
attr{"name", mapnik::value_unicode_string(u8"Test")},
|
||||
attr{"NOM_FR", mapnik::value_unicode_string(u8"Québec")},
|
||||
attr{"boolean", mapnik::value_bool(u8"true")},
|
||||
attr{"description", mapnik::value_unicode_string(u8"Test: \u005C")},
|
||||
attr{"name", tr.transcode("Test")},
|
||||
attr{"NOM_FR", tr.transcode("Québec")},
|
||||
attr{"boolean", mapnik::value_bool("true")},
|
||||
attr{"description", tr.transcode("Test: \u005C")},
|
||||
attr{"double", mapnik::value_double(1.1)},
|
||||
attr{"int", mapnik::value_integer(1)},
|
||||
attr{"object", mapnik::value_unicode_string(u8"{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false"
|
||||
u8",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true"
|
||||
u8",\"Québec\"],another_object:{name:\"nested object\"}}")},
|
||||
attr{"spaces", mapnik::value_unicode_string(u8"this has spaces")},
|
||||
attr{"array", mapnik::value_unicode_string(u8"[\"string\",\"value with spaces\",3,1.1,null,true,"
|
||||
u8"\"Québec\",{name:\"object within an array\"},"
|
||||
u8"[\"array\",\"within\",\"an\",\"array\"]]")},
|
||||
attr{"empty_array", mapnik::value_unicode_string(u8"[]")},
|
||||
attr{"empty_object", mapnik::value_unicode_string(u8"{}")},
|
||||
attr{"object", tr.transcode("{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false"
|
||||
",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true"
|
||||
",\"Québec\"],another_object:{name:\"nested object\"}}")},
|
||||
attr{"spaces", tr.transcode("this has spaces")},
|
||||
attr{"array", tr.transcode("[\"string\",\"value with spaces\",3,1.1,null,true,"
|
||||
"\"Québec\",{name:\"object within an array\"},"
|
||||
"[\"array\",\"within\",\"an\",\"array\"]]")},
|
||||
attr{"empty_array", tr.transcode("[]")},
|
||||
attr{"empty_object", tr.transcode("{}")},
|
||||
};
|
||||
auto feature = fs->next();
|
||||
REQUIRE(bool(feature));
|
||||
|
|
|
@ -51,7 +51,7 @@ bool parse_topology(std::string const& filename, mapnik::topojson::topology & to
|
|||
|
||||
}
|
||||
|
||||
TEST_CASE("topology")
|
||||
TEST_CASE("topojson")
|
||||
{
|
||||
SECTION("geometry parsing")
|
||||
{
|
||||
|
@ -91,21 +91,21 @@ TEST_CASE("topology")
|
|||
CHECK(feature);
|
||||
CHECK(feature->envelope() == bbox);
|
||||
std::initializer_list<attr> attrs = {
|
||||
attr{"name", mapnik::value_unicode_string(u8"Test")},
|
||||
attr{"NOM_FR", mapnik::value_unicode_string(u8"Québec")},
|
||||
attr{"name", tr.transcode("Test")},
|
||||
attr{"NOM_FR", tr.transcode("Québec")},
|
||||
attr{"boolean", mapnik::value_bool("true")},
|
||||
attr{"description", mapnik::value_unicode_string(u8"Test: \u005C")},
|
||||
attr{"description", tr.transcode("Test: \u005C")},
|
||||
attr{"double", mapnik::value_double(1.1)},
|
||||
attr{"int", mapnik::value_integer(1)},
|
||||
attr{"object", mapnik::value_unicode_string(u8"{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false"
|
||||
u8",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true"
|
||||
u8",\"Québec\"],another_object:{name:\"nested object\"}}")},
|
||||
attr{"spaces", mapnik::value_unicode_string(u8"this has spaces")},
|
||||
attr{"array", mapnik::value_unicode_string(u8"[\"string\",\"value with spaces\",3,1.1,null,true,"
|
||||
u8"\"Québec\",{name:\"object within an array\"},"
|
||||
u8"[\"array\",\"within\",\"an\",\"array\"]]")},
|
||||
attr{"empty_array", mapnik::value_unicode_string(u8"[]")},
|
||||
attr{"empty_object", mapnik::value_unicode_string(u8"{}")},
|
||||
attr{"object", tr.transcode("{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false"
|
||||
",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true"
|
||||
",\"Québec\"],another_object:{name:\"nested object\"}}")},
|
||||
attr{"spaces", tr.transcode("this has spaces")},
|
||||
attr{"array", tr.transcode("[\"string\",\"value with spaces\",3,1.1,null,true,"
|
||||
"\"Québec\",{name:\"object within an array\"},"
|
||||
"[\"array\",\"within\",\"an\",\"array\"]]")},
|
||||
attr{"empty_array", tr.transcode("[]")},
|
||||
attr{"empty_object", tr.transcode("{}")},
|
||||
};
|
||||
REQUIRE_ATTRIBUTES(feature, attrs);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue