@@ -2924,89 +2924,33 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length
2924
2924
}
2925
2925
}
2926
2926
2927
+ #if !os(Linux) && !os(Android) && !os(Windows)
2927
2928
// swiftlint:disable:next function_body_length
2928
2929
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}]}}} "
2937
2932
let geoPoint1 = try ParseGeoPoint ( latitude: 10.1 , longitude: 20.1 )
2938
2933
let geoPoint2 = try ParseGeoPoint ( latitude: 20.1 , longitude: 30.1 )
2939
2934
let geoPoint3 = try ParseGeoPoint ( latitude: 30.1 , longitude: 40.1 )
2940
2935
let polygon = [ geoPoint1, geoPoint2, geoPoint3]
2941
2936
let constraint = withinPolygon ( key: " yolo " , points: polygon)
2942
2937
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)
2967
2939
}
2968
2940
2969
2941
// swiftlint:disable:next function_body_length
2970
2942
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]]}}}} "
2979
2945
let geoPoint1 = try ParseGeoPoint ( latitude: 10.1 , longitude: 20.1 )
2980
2946
let geoPoint2 = try ParseGeoPoint ( latitude: 20.1 , longitude: 30.1 )
2981
2947
let geoPoint3 = try ParseGeoPoint ( latitude: 30.1 , longitude: 40.1 )
2982
2948
let polygon = try ParsePolygon ( geoPoint1, geoPoint2, geoPoint3)
2983
2949
let constraint = withinPolygon ( key: " yolo " , polygon: polygon)
2984
2950
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)
3009
2952
}
2953
+ #endif
3010
2954
3011
2955
func testWhereKeyPolygonContains( ) throws {
3012
2956
let expected : [ String : AnyCodable ] = [
0 commit comments