diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-03-07 17:47:45 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2018-03-30 03:29:44 -0700 |
commit | 06e38407d24ce6bd9cf46b04c7d3d7b74c56f94a (patch) | |
tree | cdf2bdc1c9522a208dec9c2aae86b2e8535e9ebb | |
parent | 2b9ad424ca5af8a6651a8e9eb4a3b450e3c3567a (diff) | |
download | qtlocation-mapboxgl-06e38407d24ce6bd9cf46b04c7d3d7b74c56f94a.tar.gz |
[ios, macos] Test mgl_number expressions
-rw-r--r-- | platform/darwin/test/MGLExpressionTests.mm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index 5636e5d2cc..97b3548db4 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -559,6 +559,18 @@ 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], expression); + } + { NSExpression *expression = [NSExpression expressionWithFormat:@"FUNCTION(postalCode, 'mgl_numberWithFallbackValues:', zipCode)"]; NSArray *jsonExpression = @[@"to-number", @[@"get", @"postalCode"], @[@"get", @"zipCode"]]; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); |