diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-09-19 15:20:03 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2018-10-15 13:15:46 -0700 |
commit | d0cd49f516d053620147e9f047252bd88374ac5d (patch) | |
tree | 55681fefb455cc7e3d6305c86d9a1d88e9dced84 /platform/darwin/test/MGLSymbolStyleLayerTests.mm | |
parent | ce76bde13d0f4381ee861f81daf636defaff0bc5 (diff) | |
download | qtlocation-mapboxgl-d0cd49f516d053620147e9f047252bd88374ac5d.tar.gz |
[ios, macos] Minimal darwin wrappers of 'format' expression
Add support for `MGL_FUNCTION('format', <text>, <options dictionary>)`
Diffstat (limited to 'platform/darwin/test/MGLSymbolStyleLayerTests.mm')
-rw-r--r-- | platform/darwin/test/MGLSymbolStyleLayerTests.mm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index 865de68933..42430940cd 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -224,7 +224,9 @@ XCTAssertEqual(rawLayer->getIconImage(), propertyValue, @"Setting iconImageName to a constant string with tokens should convert to an expression."); - XCTAssertEqualObjects(layer.iconImageName, [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"], + + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"]; + XCTAssertEqualObjects(layer.iconImageName, tokenExpression, @"Setting iconImageName to a constant string with tokens should convert to an expression."); } @@ -1096,20 +1098,20 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; layer.text = constantExpression; - mbgl::style::PropertyValue<std::string> propertyValue = { "Text Field" }; + mbgl::style::PropertyValue<mbgl::style::expression::Formatted> propertyValue = { "Text Field" }; XCTAssertEqual(rawLayer->getTextField(), propertyValue, @"Setting text to a constant value expression should update text-field."); XCTAssertEqualObjects(layer.text, constantExpression, @"text should round-trip constant value expressions."); - constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; + constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', 'Text Field', %@)", @{}]; NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; layer.text = functionExpression; { using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression<std::string>( - step(zoom(), literal("Text Field"), 18.0, literal("Text Field")) + propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>( + step(zoom(), format("Text Field"), 18.0, format("Text Field")) ); } @@ -1130,14 +1132,16 @@ { using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression<std::string>( - toString(get(literal("token"))) + propertyValue = mbgl::style::PropertyExpression<mbgl::style::expression::Formatted>( + format(toString(get(literal("token")))) ); } XCTAssertEqual(rawLayer->getTextField(), propertyValue, @"Setting text to a constant string with tokens should convert to an expression."); - XCTAssertEqualObjects(layer.text, [NSExpression expressionWithFormat:@"CAST(token, \"NSString\")"], + + NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', CAST(token, 'NSString'), %@)", @{}]; + XCTAssertEqualObjects(layer.text, tokenExpression, @"Setting text to a constant string with tokens should convert to an expression."); } |