diff options
Diffstat (limited to 'test/style')
-rw-r--r-- | test/style/conversion/function.test.cpp | 36 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 6 |
2 files changed, 39 insertions, 3 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp index 9e8a6b3a7f..10683458ed 100644 --- a/test/style/conversion/function.test.cpp +++ b/test/style/conversion/function.test.cpp @@ -3,6 +3,8 @@ #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/constant.hpp> #include <mbgl/style/conversion/function.hpp> +#include <mbgl/style/conversion/data_driven_property_value.hpp> +#include <mbgl/util/rapidjson.hpp> using namespace mbgl; using namespace mbgl::style; @@ -50,3 +52,37 @@ TEST(StyleConversion, Function) { ASSERT_FALSE(fn9); ASSERT_EQ("function base must be a number", error.message); } + +TEST(StyleConversion, CompositeFunctionExpression) { + Error error; + + auto parseFunction = [&](const std::string& src) { + JSDocument doc; + doc.Parse<0>(src); + return convert<DataDrivenPropertyValue<float>>(doc, error); + }; + + auto fn1 = parseFunction(R"({"expression": ["curve", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10]})"); + ASSERT_TRUE(fn1); + + auto fn2 = parseFunction(R"({ + "expression": ["coalesce", ["curve", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0] + })"); + ASSERT_TRUE(fn2); + +// auto fn3 = parseFunction(R"({ +// "expression": ["let", "a", 0, ["curve", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10] ] +// })"); +// ASSERT_TRUE(fn3); + +// auto fn4 = parseFunction(R"({ +// "expression": ["coalesce", ["let", "a", 0, ["curve", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0 ] +// })"); +// ASSERT_TRUE(fn4); + + auto fn5 = parseFunction(R"({ + "expression": ["coalesce", ["curve", ["linear"], ["number", ["get", "x"]], 0, ["zoom"], 10, 10], 0] + })"); + ASSERT_FALSE(fn5); + ASSERT_EQ(R"("zoom" expression may only be used as input to a top-level "curve" expression.)", error.message); +} diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index 0b2940a0e0..4b0e828b31 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -69,9 +69,9 @@ TEST(Stringify, Map) { } TEST(Stringify, Value) { - ASSERT_EQ(stringify(Value(true)), "true"); - ASSERT_EQ(stringify(Value(uint64_t(0))), "0"); - ASSERT_EQ(stringify(Value(1.2)), "1.2"); + ASSERT_EQ(stringify(mbgl::Value(true)), "true"); + ASSERT_EQ(stringify(mbgl::Value(uint64_t(0))), "0"); + ASSERT_EQ(stringify(mbgl::Value(1.2)), "1.2"); } TEST(Stringify, Filter) { |