summaryrefslogtreecommitdiff
path: root/platform/darwin/test
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2018-05-07 12:01:29 -0400
committerGitHub <noreply@github.com>2018-05-07 12:01:29 -0400
commita425995189c3f4c9d9040b4acff477bfc96b6afd (patch)
treecf7b68e96f6eb9c0d8066151969c42bbfc0b4763 /platform/darwin/test
parenta4892231544ccf6fcbe6dc233b5462f550cbbbcc (diff)
downloadqtlocation-mapboxgl-a425995189c3f4c9d9040b4acff477bfc96b6afd.tar.gz
[ios, macos] Add to-rgba expression operator. (#11725)
* [ios, macos] Add expression support to to-rgba operator. * [ios, macos] Update style docs. * [ios, macos] Refactored to-rgba to to-color. * [ios, macos] Add support for to-rgba expression operator. * [ios, macos] Add multiple parameters support to to-color operand. * [ios, macos] Enable to-rgba operator for MGLColor or key path expressions. * [ios, macos] Update predicates and expressions guide to reflect cast changes. * [ios, macos] Update changelogs. * [ios, macos] Clarify color casting usage.
Diffstat (limited to 'platform/darwin/test')
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm32
1 files changed, 32 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm
index 186cae609d..4ed1f61eb1 100644
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ b/platform/darwin/test/MGLExpressionTests.mm
@@ -668,6 +668,38 @@ using namespace std::string_literals;
XCTAssertEqualObjects([compatibilityExpression expressionValueWithObject:@{@"number": @1.5} context:nil], @"1.5");
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
+ {
+#if TARGET_OS_IPHONE
+ NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'UIColor')"];
+#else
+ NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'NSColor')"];
+#endif
+
+ NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"]];
+ XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
+ }
+ {
+ NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('to-color', x, y, z)"];
+ NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"], @[@"get", @"y"], @[@"get", @"z"]];
+ XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ }
+ {
+ NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(x), 'NSArray')"];
+ NSArray *jsonExpression = @[@"to-rgba", @[@"get", @"x"]];
+ XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
+ }
+ {
+ NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex(%@), 'NSArray')", MGLConstantExpression(MGLColor.blueColor)];
+ NSArray *jsonExpression = @[@"to-rgba", @[@"rgb", @0, @0, @255]];
+ XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
+ }
+ {
+ NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(noindex('x'), 'NSArray')"];
+ XCTAssertThrowsSpecificNamed(expression.mgl_jsonExpressionObject, NSException, NSInvalidArgumentException);
+ }
}
- (void)testInterpolationExpressionObject {