Skip to content

Commit 9681be7

Browse files
RISCfutureclaude
andcommitted
Guard CoreLocation import in tests for Linux compatibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 13690aa commit 9681be7

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

Tests/SwiftCIFPTests/SwiftCIFPTests.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import CoreLocation
21
import Foundation
32
import Testing
43

4+
#if canImport(CoreLocation)
5+
import CoreLocation
6+
#endif
7+
58
@testable import SwiftCIFP
69

710
// MARK: - Coordinate Tests
@@ -15,21 +18,23 @@ struct CoordinateTests {
1518
#expect(coord.longitudeDeg == -118.4081)
1619
}
1720

18-
@Test("Coordinate from CoreLocation")
19-
func fromCoreLocation() {
20-
let clCoord = CLLocationCoordinate2D(latitude: 40.6413, longitude: -73.7781)
21-
let coord = Coordinate(clCoord)
22-
#expect(coord.latitudeDeg == 40.6413)
23-
#expect(coord.longitudeDeg == -73.7781)
24-
}
21+
#if canImport(CoreLocation)
22+
@Test("Coordinate from CoreLocation")
23+
func fromCoreLocation() {
24+
let clCoord = CLLocationCoordinate2D(latitude: 40.6413, longitude: -73.7781)
25+
let coord = Coordinate(clCoord)
26+
#expect(coord.latitudeDeg == 40.6413)
27+
#expect(coord.longitudeDeg == -73.7781)
28+
}
2529

26-
@Test("Coordinate to CoreLocation")
27-
func toCoreLocation() {
28-
let coord = Coordinate(latitudeDeg: 51.4700, longitudeDeg: -0.4543)
29-
let clCoord = coord.coreLocation
30-
#expect(clCoord.latitude == 51.4700)
31-
#expect(clCoord.longitude == -0.4543)
32-
}
30+
@Test("Coordinate to CoreLocation")
31+
func toCoreLocation() {
32+
let coord = Coordinate(latitudeDeg: 51.4700, longitudeDeg: -0.4543)
33+
let clCoord = coord.coreLocation
34+
#expect(clCoord.latitude == 51.4700)
35+
#expect(clCoord.longitude == -0.4543)
36+
}
37+
#endif
3338

3439
@Test("Coordinate description")
3540
func description() {

0 commit comments

Comments
 (0)