@@ -17,8 +17,7 @@ final class GeoJSONCodableTest: XCTestCase {
1717 XCTAssertNotNil ( parsed)
1818
1919 guard
20- case let . single( geometry) = parsed,
21- case let . point( position) = geometry
20+ case let . single( . point( position) ) = parsed
2221 else { return XCTFail ( " Unexpected structure " ) }
2322
2423 XCTAssertEqual ( 0.0 , position. latitude)
@@ -54,8 +53,7 @@ final class GeoJSONCodableTest: XCTestCase {
5453 XCTAssertNotNil ( parsed)
5554
5655 guard
57- case let . single( geometry) = parsed,
58- case let . lineString( lineString) = geometry
56+ case let . single( . lineString( lineString) ) = parsed
5957 else { return XCTFail ( " Unexpected structure " ) }
6058
6159 let positions = lineString. positions
@@ -68,7 +66,6 @@ final class GeoJSONCodableTest: XCTestCase {
6866 XCTAssertEqual ( 1.0 , positions [ 1 ] . latitude)
6967 XCTAssertEqual ( 101.0 , positions [ 1 ] . longitude)
7068 XCTAssertNil ( positions [ 1 ] . altitude)
71-
7269 }
7370
7471 func testMultiLineString( ) throws {
@@ -112,8 +109,7 @@ final class GeoJSONCodableTest: XCTestCase {
112109 XCTAssertNotNil ( parsed)
113110
114111 guard
115- case let . single( geometry) = parsed,
116- case let . polygon( polygon) = geometry
112+ case let . single( . polygon( polygon) ) = parsed
117113 else { return XCTFail ( " Unexpected structure " ) }
118114
119115 let external = polygon. exterior
@@ -136,8 +132,7 @@ final class GeoJSONCodableTest: XCTestCase {
136132 XCTAssertNotNil ( parsed)
137133
138134 guard
139- case let . single( geometry) = parsed,
140- case let . polygon( polygon) = geometry,
135+ case let . single( . polygon( polygon) ) = parsed,
141136 let hole = polygon. interiors. first
142137 else { return XCTFail ( " Unexpected structure " ) }
143138
@@ -169,27 +164,35 @@ final class GeoJSONCodableTest: XCTestCase {
169164 let parsed = try JSONDecoder ( ) . decode ( GeoJSON . GeometryObject. self, from: data)
170165 XCTAssertNotNil ( parsed)
171166 }
172-
173- func testFeatureCollection( ) throws {
174- let data = try XCTestCase . loadData ( filename: " featurecollection " )
175- XCTAssertThrowsError ( try JSONDecoder ( ) . decode ( GeoJSON . GeometryObject. self, from: data) )
176- }
177167
178168 func testGeometryCollection( ) throws {
179169 let data = try XCTestCase . loadData ( filename: " geometrycollection " )
170+ let parsed = try JSONDecoder ( ) . decode ( GeoJSON . GeometryObject. self, from: data)
171+ XCTAssertNotNil ( parsed)
172+
173+ guard
174+ case let . collection( geometries) = parsed,
175+ geometries. count == 2 ,
176+ case let . single( . point( position) ) = geometries. first,
177+ case let . single( . lineString( lineString) ) = geometries. last
178+ else { return XCTFail ( " Unexpected structure " ) }
179+
180+ XCTAssertEqual ( 0.0 , position. latitude)
181+ XCTAssertEqual ( 100.0 , position. longitude)
182+ XCTAssertNil ( position. altitude)
183+
184+ XCTAssertEqual ( 0.0 , lineString. positions [ 0 ] . latitude)
185+ XCTAssertEqual ( 101.0 , lineString. positions [ 0 ] . longitude)
186+ XCTAssertNil ( lineString. positions [ 0 ] . altitude)
187+
188+ XCTAssertEqual ( 1.0 , lineString. positions [ 1 ] . latitude)
189+ XCTAssertEqual ( 102.0 , lineString. positions [ 1 ] . longitude)
190+ XCTAssertNil ( lineString. positions [ 1 ] . altitude)
191+ }
192+
193+ func testFeatureCollection( ) throws {
194+ let data = try XCTestCase . loadData ( filename: " featurecollection " )
180195 XCTAssertThrowsError ( try JSONDecoder ( ) . decode ( GeoJSON . GeometryObject. self, from: data) )
181196 }
182-
183- static var allTests = [
184- ( " testPoint " , testPoint) ,
185- ( " testMultiPoint " , testMultiPoint) ,
186- ( " testLineString " , testLineString) ,
187- ( " testMultiLineString " , testMultiLineString) ,
188- ( " testPolygon " , testPolygon) ,
189- ( " testPolygonWithHole " , testPolygonWithHole) ,
190- ( " testMultiPolygon " , testMultiPolygon) ,
191- ( " testFeatureCollection " , testFeatureCollection) ,
192- ( " testGeometryCollection " , testGeometryCollection) ,
193- ]
194197
195198}
0 commit comments