diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-03-30 16:43:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-30 16:43:55 -0700 |
commit | 59e92904c360e5aad94a1b789276bf6147120d7c (patch) | |
tree | fcb675741c492692324d841f8aaae905a3ccf8f4 /platform/darwin/test/MGLExpressionTests.mm | |
parent | b6866f764e5a804399ed60bbbce43a379b568ece (diff) | |
download | qtlocation-mapboxgl-59e92904c360e5aad94a1b789276bf6147120d7c.tar.gz |
Eviscerate mbgl expression to Foundation JSON object conversion (#11389)
* [ios, macos] Eviscerate mbgl expression to Foundation JSON object conversion
* [ios, macos] Remove literal special case
MGLJSONObjectFromMBGLValue() is just a literal translation from C++ types to Foundation types; no need for expression-specific literal wrapping.
* [ios, macos] Implemented RGB(A) operators
* [ios, macos] More robust color conversion
* [macos] Create calibrated RGB from expression on Sierra
* [macos] Calibrate colors in expressions at runtime
* [ios, macos] Special-case number conversion without fallbacks
* [ios, macos] Test mgl_number expressions
* [ios, macos] Updated tests for aftermarket expressions
* [ios, macos] Relax roundtripping requirement for serialize()
* [ios, macos] Fixed interpolation expression tests
* [ios, macos] Removed dead code
* [ios, macos] Fixed color conversion on Sierra
Diffstat (limited to 'platform/darwin/test/MGLExpressionTests.mm')
-rw-r--r-- | platform/darwin/test/MGLExpressionTests.mm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index bcc708e51e..35f97326c6 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -559,6 +559,19 @@ using namespace std::string_literals; XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], expression); } { + NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_number')"]; + NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"]]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'doubleValue')"].mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'floatValue')"].mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'decimalValue')"].mgl_jsonExpressionObject, jsonExpression); + // NSExpression is unable to evaluate NSNumber’s -floatValue, + // -doubleValue, or -decimalValue by themselves because they each return + // a primitive instead of an object. + XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], + [NSExpression expressionWithFormat:@"CAST(postalCode, 'NSNumber')"]); + } + { NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_numberWithFallbackValues:', zipCode)"]; NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"], @[@"get", @"zipCode"]]; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); @@ -624,6 +637,13 @@ using namespace std::string_literals; XCTAssertEqualObjects(compatibilityExpression.mgl_jsonExpressionObject, jsonExpression); XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], expression); } + { + NSDictionary *stops = @{@0: MGLConstantExpression(@111), @1: MGLConstantExpression(@1111)}; + NSExpression *expression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, 11, %@)", stops]; + NSArray *jsonExpression = @[@"step", @[@"zoom"], @11, @0, @111, @1, @1111]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], expression); + } } - (void)testMatchExpressionObject { |