Merge pull request #3921 from lightmare/unicode-attr-name
add test for parsing expression with non-ascii characters in attribute name
This commit is contained in:
commit
51065985df
1 changed files with 14 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
|||
#include <mapnik/unicode.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
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<std::pair<std::string, mapnik::value> > ;
|
||||
using properties_type = std::map<std::string, mapnik::value>;
|
||||
mapnik::transcoder tr("utf8");
|
||||
|
||||
properties_type prop = {{ "foo" , tr.transcode("bar") },
|
||||
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue