summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-03-14 19:20:26 -0400
committerFabian Guerra <fabian.guerra@mapbox.com>2018-03-14 19:20:26 -0400
commit7439c428a59a6964228f0b0715e110df2b89f111 (patch)
tree0236f81c123848dce74a2dc141e824479af1cc46
parent5bb19a8c68ae8d51bd73b5a4c7050baafd355de3 (diff)
downloadqtlocation-mapboxgl-7439c428a59a6964228f0b0715e110df2b89f111.tar.gz
[ios, macos] Add multiple branch tests to case expressions.
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm18
1 files changed, 14 insertions, 4 deletions
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm
index 83d4ab0d64..2e1c0e80fa 100644
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ b/platform/darwin/test/MGLExpressionTests.mm
@@ -577,10 +577,6 @@ using namespace std::string_literals;
// https://github.com/mapbox/mapbox-gl-native/issues/11007
if (@available(iOS 9.0, *)) {
{
-
- NSExpression *nested = [NSExpression expressionWithFormat:@"TERNARY( 1== 2, TERNARY(0==1, FALSE, TERNARY(4==5, FALSE, FALSE)), TERNARY(1==1, TRUE, FALSE))"];
- NSLog(@"%@", nested.mgl_jsonExpressionObject);
-
NSPredicate *conditional = [NSPredicate predicateWithFormat:@"1 = 2"];
NSExpression *trueExpression = [NSExpression expressionForConstantValue:@YES];
NSExpression *falseExpression = [NSExpression expressionForConstantValue:@NO];
@@ -598,6 +594,20 @@ using namespace std::string_literals;
XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @NO);
XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], expression);
}
+ {
+ NSExpression *expression = [NSExpression expressionWithFormat:@"TERNARY(0 = 1, TERNARY(1 = 2, TRUE, FALSE), TRUE)"];
+ NSArray *jsonExpression = @[@"case", @[@"==", @0, @1], @[@"==", @1, @2], @YES, @NO, @YES];
+ XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
+ XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @YES);
+ XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:jsonExpression], expression);
+ }
+ {
+ NSExpression *nestedExpression = [NSExpression expressionWithFormat:@"TERNARY(1 == 2, TERNARY(0 == 1, FALSE, TERNARY(4 == 5, FALSE, FALSE)), TERNARY(1 == 1, TRUE, FALSE))"];
+ NSArray *nestedJSONExpression = @[@"case", @[@"==", @1, @2], @[@"==", @0, @1], @NO, @[@"==", @4, @5], @NO, @NO, @[@"==", @1, @1], @YES, @NO];
+ XCTAssertEqualObjects(nestedExpression.mgl_jsonExpressionObject, nestedJSONExpression);
+ XCTAssertEqualObjects([nestedExpression expressionValueWithObject:nil context:nil], @YES);
+ XCTAssertEqualObjects([NSExpression mgl_expressionWithJSONObject:nestedJSONExpression], nestedExpression);
+ }
}
}