diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-28 16:39:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-02 09:44:42 -0800 |
commit | 141e995806576364d185626176c1b993fc519291 (patch) | |
tree | ecdc41fc7699f2a1a9e9456157348451ebe99597 /test/style/conversion | |
parent | 6a6bddb4537004cc1bfc506e76772de74d33f3f7 (diff) | |
download | qtlocation-mapboxgl-141e995806576364d185626176c1b993fc519291.tar.gz |
[core] Add support for data-driven styling
Diffstat (limited to 'test/style/conversion')
-rw-r--r-- | test/style/conversion/function.test.cpp | 2 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 33 |
2 files changed, 31 insertions, 4 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp index e93207ea13..5a3ec93917 100644 --- a/test/style/conversion/function.test.cpp +++ b/test/style/conversion/function.test.cpp @@ -13,7 +13,7 @@ using namespace mbgl::style::conversion; auto parseFunction(const std::string& src) { JSDocument doc; doc.Parse<0>(src); - return convert<Function<float>>(doc); + return convert<CameraFunction<float>>(doc); } TEST(StyleConversion, Function) { diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index be5d65d4ce..6814563ceb 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -79,13 +79,40 @@ TEST(Stringify, Filter) { ASSERT_EQ(stringify(EqualsFilter { "a", 1.0 }), "[\"==\",\"a\",1.0]"); } -TEST(Stringify, Function) { - ASSERT_EQ(stringify(Function<float>({{0, 1}}, 2)), "{\"base\":2.0,\"stops\":[[0.0,1.0]]}"); +TEST(Stringify, CameraFunction) { + ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 })), + "{\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + ASSERT_EQ(stringify(CameraFunction<float>(IntervalStops<float> { {{0, 1}} })), + "{\"type\":\"interval\",\"stops\":[[0.0,1.0]]}"); +} + +TEST(Stringify, SourceFunction) { + ASSERT_EQ(stringify(SourceFunction<float>("property", ExponentialStops<float> { {{0, 1}}, 2 })), + "{\"property\":\"property\",\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + ASSERT_EQ(stringify(SourceFunction<float>("property", IntervalStops<float> { {{0, 1}} })), + "{\"property\":\"property\",\"type\":\"interval\",\"stops\":[[0.0,1.0]]}"); + ASSERT_EQ(stringify(SourceFunction<float>("property", CategoricalStops<float> { {{CategoricalValue(true), 1}} })), + "{\"property\":\"property\",\"type\":\"categorical\",\"stops\":[[true,1.0]]}"); + ASSERT_EQ(stringify(SourceFunction<float>("property", IdentityStops<float> {})), + "{\"property\":\"property\",\"type\":\"identity\"}"); +} + +TEST(Stringify, CompositeFunction) { + ASSERT_EQ(stringify(CompositeFunction<float>("property", + std::map<float, ExponentialStops<float>> { + { 0, ExponentialStops<float> { {{0, 1}}, 2 } }, + { 1, ExponentialStops<float> { {{0, 1}}, 2 } } + })), + "{\"property\":\"property\",\"type\":\"exponential\",\"base\":2.0," + "\"stops\":[" + "[{\"zoom\":0.0,\"value\":0.0},1.0]," + "[{\"zoom\":1.0,\"value\":0.0},1.0]]}"); } TEST(Stringify, PropertyValue) { ASSERT_EQ(stringify(PropertyValue<float>(1)), "1.0"); - ASSERT_EQ(stringify(PropertyValue<float>(Function<float>({{0, 1}}, 2))), "{\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + ASSERT_EQ(stringify(PropertyValue<float>(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 }))), + "{\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); } TEST(Stringify, Layout) { |