From 6befc231011f2fa20c0ca50c44f4e9333397da07 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 27 Jun 2018 11:56:36 +0200 Subject: [PATCH 1/2] expressions_test: change properties_type to std::map --- test/unit/core/expressions_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/core/expressions_test.cpp b/test/unit/core/expressions_test.cpp index a01c5bdea..6c2d1580a 100644 --- a/test/unit/core/expressions_test.cpp +++ b/test/unit/core/expressions_test.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace { @@ -57,7 +57,7 @@ std::string parse_and_dump(std::string const& str) TEST_CASE("expressions") { using namespace std::placeholders; - using properties_type = std::vector > ; + using properties_type = std::map; mapnik::transcoder tr("utf8"); properties_type prop = {{ "foo" , tr.transcode("bar") }, From 5544c4c74fcd602a846283d67974c04562fba179 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 27 Jun 2018 11:58:56 +0200 Subject: [PATCH 2/2] expressions_test: add test for unicode attribute name Refs #1153 That issue doesn't affect current master, maybe it was valid at the time of posting. I just couldn't find a test that'd confirm unicode in attribute names actually works, so here it is. --- test/unit/core/expressions_test.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/unit/core/expressions_test.cpp b/test/unit/core/expressions_test.cpp index 6c2d1580a..24ad86a33 100644 --- a/test/unit/core/expressions_test.cpp +++ b/test/unit/core/expressions_test.cpp @@ -65,6 +65,7 @@ TEST_CASE("expressions") { "grass" , tr.transcode("grow")}, { "wind" , tr.transcode("blow")}, { "sky" , tr.transcode("is blue")}, + { "τ" , mapnik::value_double(6.2831853)}, { "double", mapnik::value_double(1.23456)}, { "int" , mapnik::value_integer(123)}, { "bool" , mapnik::value_bool(true)}, @@ -74,8 +75,6 @@ TEST_CASE("expressions") auto eval = std::bind(evaluate_string, feature, _1); auto approx = Approx::custom().epsilon(1e-6); - TRY_CHECK(eval(" [foo]='bar' ") == true); - // primary expressions // null TRY_CHECK(parse_and_dump("null") == "null"); @@ -98,6 +97,17 @@ TEST_CASE("expressions") TRY_CHECK(parse_and_dump("deg_to_rad") == "0.0174533"); TRY_CHECK(parse_and_dump("rad_to_deg") == "57.2958"); + // ascii attribute name + TRY_CHECK(eval(" [foo]='bar' ") == true); + + // unicode attribute name + TRY_CHECK(eval("[τ]") == prop.at("τ")); + TRY_CHECK(eval("[τ]") == eval(u8"[\u03C4]")); + + // change to TRY_CHECK once \u1234 escape sequence in attribute name + // is implemented in expression grammar + CHECK_NOFAIL(eval("[τ]") == eval("[\\u03C3]")); + // unary functions // sin / cos TRY_CHECK(eval(" sin(0.25 * pi) / cos(0.25 * pi) ").to_double() == approx(1.0));