Skip to content

Commit 545cc7a

Browse files
committed
claw back a little code coverage on Windows
1 parent 486ada7 commit 545cc7a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

FlyingSocks/Tests/AsyncSocketTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,14 @@ struct AsyncSocketTests {
188188
)
189189
}
190190

191-
#if !canImport(WinSDK)
191+
#if canImport(WinSDK)
192+
@Test
193+
func datagramPairCreation_Throws() async throws {
194+
await #expect(throws: SocketError.self) {
195+
_ = try await AsyncSocket.makeDatagramPair()
196+
}
197+
}
198+
#else
192199
@Test
193200
func datagramSocketReceivesChunk_WhenAvailable() async throws {
194201
let (s1, s2, addr) = try await AsyncSocket.makeDatagramPair()
@@ -208,7 +215,9 @@ struct AsyncSocketTests {
208215
try s2.close()
209216
try? Socket.unlink(addr)
210217
}
218+
#endif
211219

220+
#if !canImport(WinSDK)
212221
#if canImport(Darwin)
213222
@Test
214223
func messageSequence_sendsMessage_receivesTuple() async throws {

FlyingSocks/Tests/SocketTests.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,17 @@ struct SocketTests {
199199
#expect(try socket.getValue(for: .localAddressReuse) == false)
200200
}
201201

202-
#if !canImport(WinSDK)
202+
#if canImport(WinSDK)
203203
// Windows only supports setting O_NONBLOCK, and currently can't retrieve whether it's been set :)
204204
@Test
205+
func socket_Throws_On_Get_Flags() throws {
206+
let socket = try Socket(domain: AF_UNIX, type: .stream)
207+
208+
try socket.setFlags(.append) // this is "OK", but actually won't set the flag
209+
#expect(throws: SocketError.self) { try socket.flags.contains(.append) }
210+
}
211+
#else
212+
@Test
205213
func socket_Sets_And_Gets_Flags() throws {
206214
let socket = try Socket(domain: AF_UNIX, type: .stream)
207215
#expect(try socket.flags.contains(.append) == false)

0 commit comments

Comments
 (0)