diff options
Diffstat (limited to 'test/style/conversion/function.test.cpp')
-rw-r--r-- | test/style/conversion/function.test.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp index 9e8a6b3a7f..a48be2c075 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,29 @@ 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"(["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10])"); + ASSERT_TRUE(fn1); + + auto fn2 = parseFunction(R"(["coalesce", ["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0])"); + ASSERT_TRUE(fn2); + + auto fn3 = parseFunction(R"(["let", "a", 0, ["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10] ])"); + ASSERT_TRUE(fn3); + + auto fn4 = parseFunction(R"(["coalesce", ["let", "a", 0, ["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0 ])"); + ASSERT_TRUE(fn4); + + auto fn5 = parseFunction(R"(["coalesce", ["interpolate", ["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 "step" or "interpolate" expression.)", error.message); +} |