diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-01-05 12:40:54 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-01-10 15:31:12 -0800 |
commit | 76ed5079a547e9f98616a9401c8814d224cec9d8 (patch) | |
tree | 4bad1bcefd0744a0262d6973b825a977fa2cfe45 /test | |
parent | 158bd5e08cae5974a9c587677d7d8e63a36a5ff0 (diff) | |
download | qtlocation-mapboxgl-76ed5079a547e9f98616a9401c8814d224cec9d8.tar.gz |
[core, ios, macos, android] Add data-driven-styling support for `text-font`
Diffstat (limited to 'test')
-rw-r--r-- | test/style/style_parser.test.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/style/style_parser.test.cpp b/test/style/style_parser.test.cpp index 5fa81b47e9..7f7c06f4c5 100644 --- a/test/style/style_parser.test.cpp +++ b/test/style/style_parser.test.cpp @@ -102,3 +102,78 @@ TEST(StyleParser, FontStacks) { ASSERT_EQ(FontStack({"a", "b"}), result[1]); ASSERT_EQ(FontStack({"a", "b", "c"}), result[2]); } + +TEST(StyleParser, FontStacksCaseExpression) { + style::Parser parser; + parser.parse(R"({ + "version": 8, + "layers": [{ + "id": "symbol", + "type": "symbol", + "source": "vector", + "layout": { + "text-font": ["case", ["==", "a", ["string", ["get", "text-font"]]], ["literal", ["Arial"]], ["literal", ["Helvetica"]]] + } + }] + })"); + auto result = parser.fontStacks(); + ASSERT_EQ(2u, result.size()); + ASSERT_EQ(FontStack({"Arial"}), result[0]); + ASSERT_EQ(FontStack({"Helvetica"}), result[1]); +} + +TEST(StyleParser, FontStacksMatchExpression) { + style::Parser parser; + parser.parse(R"({ + "version": 8, + "layers": [{ + "id": "symbol", + "type": "symbol", + "source": "vector", + "layout": { + "text-font": ["match", ["get", "text-font"], "a", ["literal", ["Arial"]], ["literal", ["Helvetica"]]] + } + }] + })"); + auto result = parser.fontStacks(); + ASSERT_EQ(2u, result.size()); + ASSERT_EQ(FontStack({"Arial"}), result[0]); + ASSERT_EQ(FontStack({"Helvetica"}), result[1]); +} + +TEST(StyleParser, FontStacksStepExpression) { + style::Parser parser; + parser.parse(R"({ + "version": 8, + "layers": [{ + "id": "symbol", + "type": "symbol", + "source": "vector", + "layout": { + "text-font": ["array", "string", ["step", ["get", "text-font"], ["literal", ["Arial"]], 0, ["literal", ["Helvetica"]]]] + } + }] + })"); + auto result = parser.fontStacks(); + ASSERT_EQ(2u, result.size()); + ASSERT_EQ(FontStack({"Arial"}), result[0]); + ASSERT_EQ(FontStack({"Helvetica"}), result[1]); +} + +TEST(StyleParser, FontStacksGetExpression) { + // Invalid style, but not currently validated. + style::Parser parser; + parser.parse(R"({ + "version": 8, + "layers": [{ + "id": "symbol", + "type": "symbol", + "source": "vector", + "layout": { + "text-font": ["array", "string", ["get", "text-font"]] + } + }] + })"); + auto result = parser.fontStacks(); + ASSERT_EQ(0u, result.size()); +} |