[ios, macos] Fixed null expression crash

Convert NSNull into an mbgl null value.
This commit is contained in:
Minh Nguyễn
2016-12-17 15:39:43 -08:00
committed by Minh Nguyễn
parent 077cbb5e4b
commit 2c62f0a15b
2 changed files with 12 additions and 2 deletions

View File

@@ -55,9 +55,10 @@
// We use long long here to avoid any truncation.
return { (int64_t)number.longLongValue };
}
} else if (value != [NSNull null]) {
[NSException raise:@"Value not handled"
format:@"Can’t convert %s:%@ to mbgl::Value", [value objCType], value];
}
[NSException raise:@"Value not handled"
format:@"Can’t convert %s:%@ to mbgl::Value", [value objCType], value];
return { };
}

View File

@@ -197,4 +197,13 @@
}
}
#pragma mark - Null Tests
- (void)testExpressionConversionNull
{
NSComparisonPredicate *predicate = [self equalityComparisonPredicateWithRightConstantValue:[NSNull null]];
mbgl::Value convertedValue = predicate.rightExpression.mgl_filterValue;
XCTAssertTrue(convertedValue.is<mbgl::NullValue>());
}
@end