Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Test mgl_number expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Mar 16, 2018
1 parent 7bd8e57 commit ea4c49f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions platform/darwin/test/MGLExpressionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,18 @@ - (void)testTypeConversionExpressionObject {
// because it returns a primitive instead of an object.
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"]];
Expand Down

0 comments on commit ea4c49f

Please sign in to comment.