@@ -2924,89 +2924,33 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length
29242924 }
29252925 }
29262926
2927+ #if !os(Linux) && !os(Android) && !os(Windows)
29272928 // swiftlint:disable:next function_body_length
29282929 func testWhereKeyWithinPolygonPoints( ) throws {
2929- let expected : [ String : AnyCodable ] = [
2930- " yolo " : [ " $geoWithin " : [ " $polygon " : [
2931- [ 10.1 , 20.1 ] ,
2932- [ 20.1 , 30.1 ] ,
2933- [ 30.1 , 40.1 ] ]
2934- ]
2935- ]
2936- ]
2930+ // swiftlint:disable:next line_length
2931+ let expected = " { \" yolo \" :{ \" $geoWithin \" :{ \" $polygon \" :[{ \" __type \" : \" GeoPoint \" , \" latitude \" :10.1, \" longitude \" :20.100000000000001},{ \" __type \" : \" GeoPoint \" , \" latitude \" :20.100000000000001, \" longitude \" :30.100000000000001},{ \" __type \" : \" GeoPoint \" , \" latitude \" :30.100000000000001, \" longitude \" :40.100000000000001}]}}} "
29372932 let geoPoint1 = try ParseGeoPoint ( latitude: 10.1 , longitude: 20.1 )
29382933 let geoPoint2 = try ParseGeoPoint ( latitude: 20.1 , longitude: 30.1 )
29392934 let geoPoint3 = try ParseGeoPoint ( latitude: 30.1 , longitude: 40.1 )
29402935 let polygon = [ geoPoint1, geoPoint2, geoPoint3]
29412936 let constraint = withinPolygon ( key: " yolo " , points: polygon)
29422937 let query = GameScore . query ( constraint)
2943- let queryWhere = query. `where`
2944-
2945- do {
2946- let encoded = try ParseCoding . jsonEncoder ( ) . encode ( queryWhere)
2947- let decodedDictionary = try JSONDecoder ( ) . decode ( [ String : AnyCodable ] . self, from: encoded)
2948- XCTAssertEqual ( expected. keys, decodedDictionary. keys)
2949-
2950- guard let expectedValues = expected. values. first? . value as? [ String : [ String : [ [ Double ] ] ] ] ,
2951- let expectedBox = expectedValues [ " $geoWithin " ] ? [ " $polygon " ] else {
2952- XCTFail ( " Should have casted " )
2953- return
2954- }
2955-
2956- guard let decodedValues = decodedDictionary. values. first? . value as? [ String : [ String : [ [ Double ] ] ] ] ,
2957- let decodedBox = decodedValues [ " $geoWithin " ] ? [ " $polygon " ] else {
2958- XCTFail ( " Should have casted " )
2959- return
2960- }
2961- XCTAssertEqual ( expectedBox, decodedBox)
2962-
2963- } catch {
2964- XCTFail ( error. localizedDescription)
2965- return
2966- }
2938+ XCTAssertEqual ( query. where. description, expected)
29672939 }
29682940
29692941 // swiftlint:disable:next function_body_length
29702942 func testWhereKeyWithinPolygon( ) throws {
2971- let expected : [ String : AnyCodable ] = [
2972- " yolo " : [ " $geoWithin " : [ " $polygon " : [
2973- [ 10.1 , 20.1 ] ,
2974- [ 20.1 , 30.1 ] ,
2975- [ 30.1 , 40.1 ] ]
2976- ]
2977- ]
2978- ]
2943+ // swiftlint:disable:next line_length
2944+ let expected = " { \" yolo \" :{ \" $geoWithin \" :{ \" $polygon \" :{ \" __type \" : \" Polygon \" , \" coordinates \" :[[20.100000000000001,10.1],[30.100000000000001,20.100000000000001],[40.100000000000001,30.100000000000001]]}}}} "
29792945 let geoPoint1 = try ParseGeoPoint ( latitude: 10.1 , longitude: 20.1 )
29802946 let geoPoint2 = try ParseGeoPoint ( latitude: 20.1 , longitude: 30.1 )
29812947 let geoPoint3 = try ParseGeoPoint ( latitude: 30.1 , longitude: 40.1 )
29822948 let polygon = try ParsePolygon ( geoPoint1, geoPoint2, geoPoint3)
29832949 let constraint = withinPolygon ( key: " yolo " , polygon: polygon)
29842950 let query = GameScore . query ( constraint)
2985- let queryWhere = query. `where`
2986-
2987- do {
2988- let encoded = try ParseCoding . jsonEncoder ( ) . encode ( queryWhere)
2989- let decodedDictionary = try JSONDecoder ( ) . decode ( [ String : AnyCodable ] . self, from: encoded)
2990- XCTAssertEqual ( expected. keys, decodedDictionary. keys)
2991-
2992- guard let expectedValues = expected. values. first? . value as? [ String : [ String : [ [ Double ] ] ] ] ,
2993- let expectedBox = expectedValues [ " $geoWithin " ] ? [ " $polygon " ] else {
2994- XCTFail ( " Should have casted " )
2995- return
2996- }
2997-
2998- guard let decodedValues = decodedDictionary. values. first? . value as? [ String : [ String : [ [ Double ] ] ] ] ,
2999- let decodedBox = decodedValues [ " $geoWithin " ] ? [ " $polygon " ] else {
3000- XCTFail ( " Should have casted " )
3001- return
3002- }
3003- XCTAssertEqual ( expectedBox, decodedBox)
3004-
3005- } catch {
3006- XCTFail ( error. localizedDescription)
3007- return
3008- }
2951+ XCTAssertEqual ( query. where. description, expected)
30092952 }
2953+ #endif
30102954
30112955 func testWhereKeyPolygonContains( ) throws {
30122956 let expected : [ String : AnyCodable ] = [
0 commit comments