summaryrefslogtreecommitdiff
path: root/test/style/conversion
diff options
context:
space:
mode:
Diffstat (limited to 'test/style/conversion')
-rw-r--r--test/style/conversion/function.test.cpp14
-rw-r--r--test/style/conversion/layer.test.cpp18
-rw-r--r--test/style/conversion/light.test.cpp14
-rw-r--r--test/style/conversion/stringify.test.cpp17
4 files changed, 30 insertions, 33 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp
index 08637d40cb..1eff94d939 100644
--- a/test/style/conversion/function.test.cpp
+++ b/test/style/conversion/function.test.cpp
@@ -19,26 +19,26 @@ TEST(StyleConversion, Function) {
return convert<CameraFunction<float>, JSValue>(doc, error);
};
- auto fn1 = parseFunction("{\"stops\":[]}");
+ auto fn1 = parseFunction(R"({"stops":[]})");
ASSERT_FALSE(fn1);
ASSERT_EQ("function must have at least one stop", error.message);
- auto fn2 = parseFunction("{\"stops\":[1]}");
+ auto fn2 = parseFunction(R"({"stops":[1]})");
ASSERT_FALSE(fn2);
ASSERT_EQ("function stop must be an array", error.message);
- auto fn3 = parseFunction("{\"stops\":[[]]}");
+ auto fn3 = parseFunction(R"({"stops":[[]]})");
ASSERT_FALSE(fn3);
ASSERT_EQ("function stop must have two elements", error.message);
- auto fn4 = parseFunction("{\"stops\":[[-1,-1]]}");
+ auto fn4 = parseFunction(R"({"stops":[[-1,-1]]})");
ASSERT_TRUE(bool(fn4));
- auto fn5 = parseFunction("{\"stops\":[[0,1,2]]}");
+ auto fn5 = parseFunction(R"({"stops":[[0,1,2]]})");
ASSERT_FALSE(fn5);
ASSERT_EQ("function stop must have two elements", error.message);
- auto fn6 = parseFunction("{\"stops\":[[0,\"x\"]]}");
+ auto fn6 = parseFunction(R"({"stops":[[0,"x"]]})");
ASSERT_FALSE(fn6);
ASSERT_EQ("value must be a number", error.message);
@@ -50,7 +50,7 @@ TEST(StyleConversion, Function) {
ASSERT_FALSE(fn8);
ASSERT_EQ("function must be an object", error.message);
- auto fn9 = parseFunction("{\"stops\":[[0,0]],\"base\":false}");
+ auto fn9 = parseFunction(R"({"stops":[[0,0]],"base":false})");
ASSERT_FALSE(fn9);
ASSERT_EQ("function base must be a number", error.message);
}
diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp
index ae8d4058ab..d51d7d33e2 100644
--- a/test/style/conversion/layer.test.cpp
+++ b/test/style/conversion/layer.test.cpp
@@ -27,21 +27,11 @@ TEST(StyleConversion, LayerTransition) {
"duration": 400,
"delay": 500
}
- },
- "paint.class": {
- "background-color-transition": {
- "duration": 100
- }
}
})JSON");
- ASSERT_EQ(400ms, *layer->as<BackgroundLayer>()->impl->cascading
- .get<BackgroundColor>().getTransition({}).duration);
- ASSERT_EQ(500ms, *layer->as<BackgroundLayer>()->impl->cascading
- .get<BackgroundColor>().getTransition({}).delay);
-
- ASSERT_EQ(100ms, *layer->as<BackgroundLayer>()->impl->cascading
- .get<BackgroundColor>().getTransition({"class"}).duration);
- ASSERT_FALSE(bool(layer->as<BackgroundLayer>()->impl->cascading
- .get<BackgroundColor>().getTransition({"class"}).delay));
+ ASSERT_EQ(400ms, *layer->as<BackgroundLayer>()->impl().paint
+ .get<BackgroundColor>().options.duration);
+ ASSERT_EQ(500ms, *layer->as<BackgroundLayer>()->impl().paint
+ .get<BackgroundColor>().options.delay);
}
diff --git a/test/style/conversion/light.test.cpp b/test/style/conversion/light.test.cpp
index a2185906d6..28e22b3550 100644
--- a/test/style/conversion/light.test.cpp
+++ b/test/style/conversion/light.test.cpp
@@ -30,7 +30,7 @@ TEST(StyleConversion, Light) {
}
{
- auto light = parseLight("{\"color\":{\"stops\":[[14,\"blue\"],[16,\"red\"]]},\"intensity\":0.3,\"position\":[3,90,90]}");
+ auto light = parseLight(R"({"color":{"stops":[[14,"blue"],[16,"red"]]},"intensity":0.3,"position":[3,90,90]})");
ASSERT_TRUE((bool) light);
ASSERT_TRUE(light->getAnchor().isUndefined());
@@ -54,7 +54,7 @@ TEST(StyleConversion, Light) {
}
{
- auto light = parseLight("{\"color\":\"blue\",\"intensity\":0.3,\"color-transition\":{\"duration\":1000}}");
+ auto light = parseLight(R"({"color":"blue","intensity":0.3,"color-transition":{"duration":1000}})");
ASSERT_TRUE((bool) light);
ASSERT_FALSE(light->getColor().isUndefined());
@@ -65,35 +65,35 @@ TEST(StyleConversion, Light) {
}
{
- auto light = parseLight("{\"intensity\":false}");
+ auto light = parseLight(R"({"intensity":false})");
ASSERT_FALSE((bool) light);
ASSERT_EQ("value must be a number", error.message);
}
{
- auto light = parseLight("{\"intensity\":{\"stops\":[[15,\"red\"],[17,\"blue\"]]}}");
+ auto light = parseLight(R"({"intensity":{"stops":[[15,"red"],[17,"blue"]]}})");
ASSERT_FALSE((bool) light);
ASSERT_EQ("value must be a number", error.message);
}
{
- auto light = parseLight("{\"color\":5}");
+ auto light = parseLight(R"({"color":5})");
ASSERT_FALSE((bool) light);
ASSERT_EQ("value must be a string", error.message);
}
{
- auto light = parseLight("{\"position\":[0,5]}");
+ auto light = parseLight(R"({"position":[0,5]})");
ASSERT_FALSE((bool) light);
ASSERT_EQ("value must be an array of 3 numbers", error.message);
}
{
- auto light = parseLight("{\"anchor\":\"something\"}");
+ auto light = parseLight(R"({"anchor":"something"})");
ASSERT_FALSE((bool) light);
ASSERT_EQ("value must be a valid enumeration value", error.message);
diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp
index 1dae20b26b..0b2940a0e0 100644
--- a/test/style/conversion/stringify.test.cpp
+++ b/test/style/conversion/stringify.test.cpp
@@ -121,10 +121,17 @@ TEST(Stringify, PropertyValue) {
}
TEST(Stringify, Layout) {
- ASSERT_EQ(stringify(SymbolLayoutProperties()), "{}");
-
- SymbolLayoutProperties layout;
- layout.unevaluated.get<SymbolAvoidEdges>() = true;
- layout.unevaluated.get<IconPadding>() = 2.0;
+ auto stringify = [] (const SymbolLayoutProperties::Unevaluated& layout) {
+ rapidjson::StringBuffer s;
+ rapidjson::Writer<rapidjson::StringBuffer> writer(s);
+ layout.stringify(writer);
+ return std::string(s.GetString());
+ };
+
+ ASSERT_EQ(stringify(SymbolLayoutProperties::Unevaluated()), "{}");
+
+ SymbolLayoutProperties::Unevaluated layout;
+ layout.get<SymbolAvoidEdges>() = true;
+ layout.get<IconPadding>() = 2.0;
ASSERT_EQ(stringify(layout), "{\"symbol-avoid-edges\":true,\"icon-padding\":2.0}");
}