diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-13 18:14:12 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-20 11:56:30 -0700 |
commit | c8edbb0500cbf4baf1d5fdb0e63679539e166585 (patch) | |
tree | 750f3b72b9e3b1c91ddbc0541cfc64d7d80ffe71 /test/style/conversion | |
parent | 6d7072162b764c2432c010cd463a5a2c0093d606 (diff) | |
download | qtlocation-mapboxgl-c8edbb0500cbf4baf1d5fdb0e63679539e166585.tar.gz |
[core] Replace {Source,Camera,Composite}Function with PropertyExpression
Diffstat (limited to 'test/style/conversion')
-rw-r--r-- | test/style/conversion/function.test.cpp | 15 | ||||
-rw-r--r-- | test/style/conversion/light.test.cpp | 11 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 16 |
3 files changed, 17 insertions, 25 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp index a48be2c075..fa89576afa 100644 --- a/test/style/conversion/function.test.cpp +++ b/test/style/conversion/function.test.cpp @@ -2,9 +2,8 @@ #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/constant.hpp> -#include <mbgl/style/conversion/function.hpp> +#include <mbgl/style/conversion/property_value.hpp> #include <mbgl/style/conversion/data_driven_property_value.hpp> -#include <mbgl/util/rapidjson.hpp> using namespace mbgl; using namespace mbgl::style; @@ -14,7 +13,7 @@ TEST(StyleConversion, Function) { Error error; auto parseFunction = [&](const std::string& json) { - return convertJSON<CameraFunction<float>>(json, error); + return convertJSON<PropertyValue<float>>(json, error); }; auto fn1 = parseFunction(R"({"stops":[]})"); @@ -46,7 +45,7 @@ TEST(StyleConversion, Function) { auto fn8 = parseFunction("[]"); ASSERT_FALSE(fn8); - ASSERT_EQ("function must be an object", error.message); + ASSERT_EQ("value must be a number", error.message); auto fn9 = parseFunction(R"({"stops":[[0,0]],"base":false})"); ASSERT_FALSE(fn9); @@ -56,10 +55,8 @@ TEST(StyleConversion, Function) { TEST(StyleConversion, CompositeFunctionExpression) { Error error; - auto parseFunction = [&](const std::string& src) { - JSDocument doc; - doc.Parse<0>(src); - return convert<DataDrivenPropertyValue<float>>(doc, error); + auto parseFunction = [&](const std::string& json) { + return convertJSON<DataDrivenPropertyValue<float>>(json, error); }; auto fn1 = parseFunction(R"(["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10])"); @@ -71,7 +68,7 @@ TEST(StyleConversion, CompositeFunctionExpression) { 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 ])"); + 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])"); diff --git a/test/style/conversion/light.test.cpp b/test/style/conversion/light.test.cpp index 67e48c942e..f111e40ff3 100644 --- a/test/style/conversion/light.test.cpp +++ b/test/style/conversion/light.test.cpp @@ -32,22 +32,23 @@ TEST(StyleConversion, Light) { ASSERT_TRUE(light->getAnchor().isUndefined()); ASSERT_FALSE(light->getAnchor().isConstant()); - ASSERT_FALSE(light->getAnchor().isCameraFunction()); + ASSERT_FALSE(light->getAnchor().isExpression()); ASSERT_FALSE(light->getIntensity().isUndefined()); ASSERT_TRUE(light->getIntensity().isConstant()); ASSERT_EQ(light->getIntensity().asConstant(), 0.3f); - ASSERT_FALSE(light->getAnchor().isCameraFunction()); + ASSERT_FALSE(light->getIntensity().isExpression()); ASSERT_FALSE(light->getColor().isUndefined()); ASSERT_FALSE(light->getColor().isConstant()); - ASSERT_TRUE(light->getColor().isCameraFunction()); + ASSERT_TRUE(light->getColor().isExpression()); + ASSERT_FALSE(light->getColor().asExpression().isZoomConstant()); ASSERT_FALSE(light->getPosition().isUndefined()); ASSERT_TRUE(light->getPosition().isConstant()); std::array<float, 3> expected{{ 3, 90, 90 }}; ASSERT_EQ(light->getPosition().asConstant(), mbgl::style::Position({ expected })); - ASSERT_FALSE(light->getPosition().isCameraFunction()); + ASSERT_FALSE(light->getPosition().isExpression()); } { @@ -56,7 +57,7 @@ TEST(StyleConversion, Light) { ASSERT_FALSE(light->getColor().isUndefined()); ASSERT_TRUE(light->getColor().isConstant()); - ASSERT_FALSE(light->getColor().isCameraFunction()); + ASSERT_FALSE(light->getColor().isExpression()); ASSERT_EQ(light->getColorTransition().duration, mbgl::Duration(mbgl::Milliseconds(1000))); ASSERT_FALSE((bool) light->getColorTransition().delay); } diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index bc73b0cedb..8bc78098cd 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -82,9 +82,9 @@ TEST(Stringify, Filter) { ASSERT_EQ(stringify(Filter(eq(literal("a"), literal("b")))), "[\"==\",\"a\",\"b\"]"); } -TEST(Stringify, CameraFunction) { +TEST(Stringify, PropertyExpression) { using namespace mbgl::style::expression::dsl; - ASSERT_EQ(stringify(CameraFunction<float>( + ASSERT_EQ(stringify(PropertyExpression<float>( interpolate( linear(), zoom(), @@ -92,11 +92,8 @@ TEST(Stringify, CameraFunction) { 1.0, literal(2.0) ))), "[\"interpolate\",[\"linear\"],[\"zoom\"],0.0,1.0,1.0,2.0]"); -} -TEST(Stringify, SourceFunction) { - using namespace mbgl::style::expression::dsl; - ASSERT_EQ(stringify(SourceFunction<float>( + ASSERT_EQ(stringify(PropertyExpression<float>( interpolate( exponential(2.0), number(get("property")), @@ -104,11 +101,8 @@ TEST(Stringify, SourceFunction) { 1.0, literal(2.0) ))), "[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0,1.0,2.0]"); -} -TEST(Stringify, CompositeFunction) { - using namespace mbgl::style::expression::dsl; - ASSERT_EQ(stringify(CompositeFunction<float>( + ASSERT_EQ(stringify(PropertyExpression<float>( interpolate( linear(), zoom(), @@ -125,7 +119,7 @@ TEST(Stringify, CompositeFunction) { TEST(Stringify, PropertyValue) { using namespace mbgl::style::expression::dsl; ASSERT_EQ(stringify(PropertyValue<float>(1)), "1.0"); - ASSERT_EQ(stringify(PropertyValue<float>(CameraFunction<float>( + ASSERT_EQ(stringify(PropertyValue<float>(PropertyExpression<float>( interpolate( exponential(2.0), zoom(), |