Skip to content

Commit

Permalink
Add availability guards to Duration conversion tests. (#1746)
Browse files Browse the repository at this point in the history
For some reason the compiler didn't complain at me for not having these,
despite it complaining at me (correctly) if they weren't in the runtime.
My tests ran locally fine without the guards, but our Bazel builds were
failing without them.
  • Loading branch information
allevato authored Jan 15, 2025
1 parent e9b49af commit 42195e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Tests/SwiftProtobufTests/Test_Duration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ final class Test_Duration: XCTestCase, PBTestHelpers {
}

func testConvertFromStdlibDuration() throws {
guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else {
throw XCTSkip("Duration is not supported on this platform")
}

// Full precision
do {
let sd = Duration.seconds(123) + .nanoseconds(123_456_789)
Expand Down Expand Up @@ -372,6 +376,10 @@ final class Test_Duration: XCTestCase, PBTestHelpers {
}

func testConvertToStdlibDuration() throws {
guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else {
throw XCTSkip("Duration is not supported on this platform")
}

do {
let pd = Google_Protobuf_Duration(seconds: 123, nanos: 123_456_789)
let sd = Duration(pd)
Expand Down

0 comments on commit 42195e7

Please sign in to comment.