diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2019-03-07 19:28:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 19:28:20 -0800 |
commit | 79f3307c4be67ee1f9be1e90e4d5d2031e27ab8e (patch) | |
tree | 192396b53664ca8b983453e1ced4ce36582d0904 /platform/darwin/test/MGLExpressionTests.mm | |
parent | d0ffaa4245802c2081f899eaed80b730558c9227 (diff) | |
download | qtlocation-mapboxgl-79f3307c4be67ee1f9be1e90e4d5d2031e27ab8e.tar.gz |
[ios, macos] Fix a bug with multiple format expressions. (#14064)
Fixed a bug where `format` expressions using the generic `MGL_FUNCTION` binding ignored multiple formatting parameters.
Diffstat (limited to 'platform/darwin/test/MGLExpressionTests.mm')
-rw-r--r-- | platform/darwin/test/MGLExpressionTests.mm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index f869275dd3..bcc30e49fd 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -1002,6 +1002,23 @@ using namespace std::string_literals; XCTAssertThrowsSpecificNamed([expression expressionValueWithObject:nil context:nil], NSException, NSInvalidArgumentException); } { + NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('format', 'foo', %@, '\r', %@, 'biz', %@, 'bar', %@)", @{@"font-scale": @1.2}, @{}, @{@"font-scale": @1.0}, @{@"font-scale": @0.8}]; + NSArray *jsonExpression = @[@"format", @"foo", @{@"font-scale": @1.2}, @"\r", @{}, @"biz", @{@"font-scale": @1.0}, @"bar", @{@"font-scale": @0.8}]; + + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + + NSExpression *encodedExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression]; + + // Expressions encoded from a json create a different constant abstract type + // thus even tho knowing that the constant values are the same, the base + // class is not. This compares the resulting array which is type agnostic encoding. + for (NSUInteger index = 0; index < jsonExpression.count; index++) { + NSExpression *left = encodedExpression.mgl_jsonExpressionObject[index]; + NSExpression *right = expression.mgl_jsonExpressionObject[index]; + XCTAssertEqualObjects(left.mgl_jsonExpressionObject, right.mgl_jsonExpressionObject); + } + } + { NSArray *arguments = @[ MGLConstantExpression(@"one"), MGLConstantExpression(@1), [NSExpression expressionForVariable:@"one"], |