Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Neel Mistry committed Sep 27, 2021
1 parent 9403805 commit 51715be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ extension TileRegionLoadOptions {
}
}

guard let geometry = geometry else {
return nil
var commonGeometry: MapboxCommon.Geometry?
if let geometry = geometry {
commonGeometry = MapboxCommon.Geometry(geometry: geometry)
}

self.init(__geometry: MapboxCommon.Geometry(geometry: geometry),
self.init(__geometry: commonGeometry,
descriptors: descriptors.isEmpty ? nil : descriptors,
metadata: metadata,
acceptExpired: acceptExpired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,31 @@ internal class OfflineManagerIntegrationTestCase: IntegrationTestCase {
closure = nil
XCTAssertNil(weakTileStore)
}

func testGeometryFromNonWrappedTileRegionLoadOptions() {
let nonWrappedTileRegionLoadOptions = TileRegionLoadOptions.init(__geometry: MapboxCommon.Geometry(geometry: .point(Point(self.tokyoCoord))),
descriptors: nil,
metadata: nil,
acceptExpired: false,
networkRestriction: .none,
start: nil,
averageBytesPerSecond: nil,
extraOptions: nil)

XCTAssertNotNil(nonWrappedTileRegionLoadOptions.geometry)
XCTAssertEqual(nonWrappedTileRegionLoadOptions.geometry!.type, .Point)

let geo = nonWrappedTileRegionLoadOptions.geometry!.value as! Point
XCTAssertEqual(geo, Point(self.tokyoCoord))
}

func testGeometryFromWrappedTileRegionLoadOptions() {
let wrappedTileRegionLoadOptions = TileRegionLoadOptions(geometry: .point(Point(self.tokyoCoord)),
descriptors: [])
XCTAssertNotNil(wrappedTileRegionLoadOptions?.geometry)
XCTAssertEqual(wrappedTileRegionLoadOptions?.geometry!.type, .Point)

let geo = wrappedTileRegionLoadOptions?.geometry!.value as! Point
XCTAssertEqual(geo, Point(self.tokyoCoord))
}
}

0 comments on commit 51715be

Please sign in to comment.