add transform expressions tests (https://github.com/mapnik/mapnik/pull/141\
6) (ref #3569)
This commit is contained in:
parent
65dcb1c935
commit
fa7851ea06
1 changed files with 57 additions and 0 deletions
57
test/unit/core/transform_expressions_test.cpp
Normal file
57
test/unit/core/transform_expressions_test.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/parse_transform.hpp>
|
||||
#include <mapnik/transform_expression.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
bool test_transform_expressions(std::string const& in, std::string const& out)
|
||||
{
|
||||
auto tr_list = mapnik::parse_transform(in);
|
||||
return mapnik::to_expression_string(*tr_list) == out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("transform-expressions")
|
||||
{
|
||||
// matrix
|
||||
CHECK(test_transform_expressions("matrix( 1,2,3,4,5, 6)", "matrix(1, 2, 3, 4, 5, 6)"));
|
||||
CHECK(test_transform_expressions("matrix(1 2 3 4 5 6)", "matrix(1, 2, 3, 4, 5, 6)"));
|
||||
CHECK(test_transform_expressions("matrix(1,2,3,4,5,4*2-1)", "matrix(1, 2, 3, 4, 5, (4*2-1))"));
|
||||
|
||||
// translate
|
||||
CHECK(test_transform_expressions("translate(100)", "translate(100)"));
|
||||
CHECK(test_transform_expressions("translate([tx])", "translate([tx])"));
|
||||
CHECK(test_transform_expressions("translate(100 200)", "translate(100, 200)"));
|
||||
CHECK(test_transform_expressions("translate([tx],[ty])", "translate([tx], [ty])"));
|
||||
CHECK(test_transform_expressions("translate([tx],200)", "translate([tx], 200)"));
|
||||
CHECK(test_transform_expressions("translate(100,[ty])", "translate(100, [ty])"));
|
||||
|
||||
// scale
|
||||
CHECK(test_transform_expressions("scale(1.5)", "scale(1.5)"));
|
||||
CHECK(test_transform_expressions("scale([sx])", "scale([sx])"));
|
||||
CHECK(test_transform_expressions("scale([sx],1.5)", "scale([sx], 1.5)"));
|
||||
CHECK(test_transform_expressions("scale(1.5,[sy])", "scale(1.5, [sy])"));
|
||||
CHECK(test_transform_expressions("scale([sx],[sy]/2)", "scale([sx], [sy]/2)"));
|
||||
|
||||
// rotate
|
||||
CHECK(test_transform_expressions("rotate([a] -2)", "rotate(([a]-2))"));
|
||||
CHECK(test_transform_expressions("rotate([a] -2 -3)", "rotate((([a]-2)-3))"));
|
||||
CHECK(test_transform_expressions("rotate([a],-2,-3)", "rotate([a], -2, -3)"));
|
||||
CHECK(test_transform_expressions("rotate([a] -2 -3 -4)", "rotate(((([a]-2)-3)-4))"));
|
||||
CHECK(test_transform_expressions("rotate([a] -2, 3, 4)", "rotate(([a]-2), 3, 4)"));
|
||||
|
||||
// skewX
|
||||
CHECK(test_transform_expressions("skewX(2)", "skewX(2)"));
|
||||
CHECK(test_transform_expressions("skewX(2*[x]+[y])", "skewX((2*[x]+[y]))"));
|
||||
|
||||
// skewY
|
||||
CHECK(test_transform_expressions("skewY(2)", "skewY(2)"));
|
||||
CHECK(test_transform_expressions("skewY(2*[x]+[y])", "skewY((2*[x]+[y]))"));
|
||||
|
||||
// compound
|
||||
CHECK(test_transform_expressions("translate([tx]) rotate([a])", "translate([tx]) rotate([a])"));
|
||||
CHECK(test_transform_expressions("rotate(30+[a]) scale(2*[sx],[sy])", "rotate((30+[a])) scale(2*[sx], [sy])"));
|
||||
}
|
Loading…
Reference in a new issue