Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Tests/BytesTests/AsyncByteIteratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Testing

#if canImport(Darwin)
@Suite struct LegacyAsyncByteIteratorTests {
#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -22,6 +23,7 @@ import Testing
_ = try await iterator.next(Bytes.self, count: -1)
}
}
#endif

@Test func nextCount() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand Down Expand Up @@ -53,6 +55,7 @@ import Testing
#expect(try await iterator.next(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -79,6 +82,7 @@ import Testing
_ = try await iterator.next(Bytes.self, min: 1, max: 0)
}
}
#endif

@Test func nextMinMax() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand Down Expand Up @@ -106,6 +110,7 @@ import Testing
}
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -116,6 +121,7 @@ import Testing
_ = try await iterator.next(Bytes.self, max: -1)
}
}
#endif

@Test func nextMax() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -139,6 +145,7 @@ import Testing
}
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -149,6 +156,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, count: -1)
}
}
#endif

@Test func nextIfPresentCount() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand Down Expand Up @@ -194,6 +202,7 @@ import Testing
#expect(try await iterator.nextIfPresent(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -220,6 +229,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, min: 1, max: 0)
}
}
#endif

@Test func nextIfPresentMinMax() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand Down Expand Up @@ -260,6 +270,7 @@ import Testing
#expect(try await iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil)
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand All @@ -270,6 +281,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, max: -1)
}
}
#endif

@Test func nextIfPresentMax() async throws {
var iterator = AsyncTestIterator([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07])
Expand Down Expand Up @@ -462,6 +474,7 @@ import Testing
#endif

@Suite struct AsyncByteIteratorTests {
#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand All @@ -473,6 +486,7 @@ import Testing
_ = try await iterator.next(Bytes.self, count: -1)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextCount() async throws {
Expand Down Expand Up @@ -506,6 +520,7 @@ import Testing
#expect(try await iterator.next(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand Down Expand Up @@ -533,6 +548,7 @@ import Testing
_ = try await iterator.next(Bytes.self, min: 1, max: 0)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextMinMax() async throws {
Expand Down Expand Up @@ -562,6 +578,7 @@ import Testing
}
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand All @@ -573,6 +590,7 @@ import Testing
_ = try await iterator.next(Bytes.self, max: -1)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextMax() async throws {
Expand All @@ -598,6 +616,7 @@ import Testing
}
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand All @@ -609,6 +628,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, count: -1)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentCount() async throws {
Expand Down Expand Up @@ -657,6 +677,7 @@ import Testing
#expect(try await iterator.nextIfPresent(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand Down Expand Up @@ -684,6 +705,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, min: 1, max: 0)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentMinMax() async throws {
Expand Down Expand Up @@ -727,6 +749,7 @@ import Testing
#expect(try await iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil)
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
Expand All @@ -738,6 +761,7 @@ import Testing
_ = try await iterator.nextIfPresent(Bytes.self, max: -1)
}
}
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
@Test func nextIfPresentMax() async throws {
Expand Down
2 changes: 2 additions & 0 deletions Tests/BytesTests/AsyncChunkedBytesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Bytes
import Testing

@Suite struct AsyncChunkedBytesTests {
#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func chunkedInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let sequence = AsyncTestSequence()
Expand All @@ -29,6 +30,7 @@ import Testing
_ = sequence.chuncked(0)
}
}
#endif

@Test func chunked() async throws {
let sequence = AsyncTestSequence()
Expand Down
12 changes: 12 additions & 0 deletions Tests/BytesTests/ByteIteratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import Testing
@Suite struct ByteIteratorTests {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
var iterator = bytes.makeIterator()
_ = try iterator.next(Bytes.self, count: -1)
}
}
#endif

@Test func nextCount() async throws {
var iterator = bytes.makeIterator()
Expand All @@ -36,6 +38,7 @@ import Testing
#expect(try iterator.next(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
Expand All @@ -53,6 +56,7 @@ import Testing
_ = try iterator.next(Bytes.self, min: 1, max: 0)
}
}
#endif

@Test func nextMinMax() async throws {
var iterator = bytes.makeIterator()
Expand All @@ -68,13 +72,15 @@ import Testing
}
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
var iterator = bytes.makeIterator()
_ = iterator.next(Bytes.self, max: -1)
}
}
#endif

@Test func nextMax() async throws {
var iterator = bytes.makeIterator()
Expand All @@ -86,13 +92,15 @@ import Testing
#expect(iterator.next(Bytes.self, max: 3) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentCountInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
var iterator = bytes.makeIterator()
_ = try iterator.nextIfPresent(Bytes.self, count: -1)
}
}
#endif

@Test func nextIfPresentCount() async throws {
var iterator = bytes.makeIterator()
Expand Down Expand Up @@ -122,6 +130,7 @@ import Testing
#expect(try iterator.nextIfPresent(Bytes.self, count: 0) == [])
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentMinMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
Expand All @@ -139,6 +148,7 @@ import Testing
_ = try iterator.nextIfPresent(Bytes.self, min: 1, max: 0)
}
}
#endif

@Test func nextIfPresentMinMax() async throws {
var iterator = bytes.makeIterator()
Expand All @@ -165,13 +175,15 @@ import Testing
#expect(try iterator.nextIfPresent(Bytes.self, min: 0, max: 3) == nil)
}

#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
@Test func nextIfPresentMaxInvalidInput() async throws {
await #expect(processExitsWith: .failure) {
let bytes: Bytes = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
var iterator = bytes.makeIterator()
_ = iterator.nextIfPresent(Bytes.self, max: -1)
}
}
#endif

@Test func nextIfPresentMax() async throws {
var iterator = bytes.makeIterator()
Expand Down
Loading