Skip to content

Commit 00071f1

Browse files
committed
Update availability checks, move the tests to the 6.2-guarded area
1 parent cc1475b commit 00071f1

File tree

3 files changed

+46
-50
lines changed

3 files changed

+46
-50
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [main]
66
schedule:
7-
# - cron: "0 8,20 * * *"
7+
- cron: "0 8,20 * * *"
88

99
jobs:
1010
unit-tests:

Sources/NIOCore/ByteBuffer-aux.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ extension ByteBuffer {
5959
}
6060

6161
#if compiler(>=6.2)
62-
@_spi(InlineArray)
6362
@inlinable
63+
@available(macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26, *)
6464
public mutating func readInlineArray<
6565
let count: Int,
6666
IntegerType: FixedWidthInteger

Tests/NIOCoreTests/ByteBufferTest.swift

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import _NIOBase64
1919

2020
import struct Foundation.Data
2121

22-
@testable @_spi(InlineArray) import NIOCore
22+
@testable import NIOCore
2323

2424
class ByteBufferTest: XCTestCase {
2525
private let allocator = ByteBufferAllocator()
@@ -3932,53 +3932,6 @@ extension ByteBufferTest {
39323932
XCTAssertEqual(0, self.buf.readableBytes, "Buffer should be fully consumed after all reads.")
39333933
}
39343934

3935-
func testReadInlineArrayOfUInt8() throws {
3936-
#if compiler(>=6.2)
3937-
let bytes = (0..<10).map { _ in UInt8.random(in: .min ... .max) }
3938-
3939-
let startWriterIndex = self.buf.writerIndex
3940-
let written = self.buf.writeBytes(bytes)
3941-
XCTAssertEqual(startWriterIndex + written, self.buf.writerIndex)
3942-
XCTAssertEqual(written, self.buf.readableBytes)
3943-
3944-
let result = try XCTUnwrap(
3945-
self.buf.readInlineArray(as: InlineArray<10, UInt8>.self)
3946-
)
3947-
XCTAssertEqual(10, result.count)
3948-
for idx in result.indices {
3949-
XCTAssertEqual(bytes[idx], result[idx])
3950-
}
3951-
XCTAssertEqual(0, self.buf.readableBytes)
3952-
#else
3953-
throw XCTSkip("'InlineArray' is only available in Swift 6.2 and later")
3954-
#endif // compiler(>=6.2)
3955-
}
3956-
3957-
func testReadInlineArrayOfUInt64() throws {
3958-
#if compiler(>=6.2)
3959-
let bytes = (0..<10).map { _ in UInt64.random(in: .min ... .max) }
3960-
3961-
let startWriterIndex = self.buf.writerIndex
3962-
var written = 0
3963-
for byte in bytes {
3964-
written += self.buf.writeInteger(byte)
3965-
}
3966-
XCTAssertEqual(startWriterIndex + written, self.buf.writerIndex)
3967-
XCTAssertEqual(written, self.buf.readableBytes)
3968-
3969-
let result = try XCTUnwrap(
3970-
self.buf.readInlineArray(as: InlineArray<10, UInt64>.self)
3971-
)
3972-
XCTAssertEqual(10, result.count)
3973-
for idx in result.indices {
3974-
XCTAssertEqual(bytes[idx], result[idx])
3975-
}
3976-
XCTAssertEqual(0, self.buf.readableBytes)
3977-
#else
3978-
throw XCTSkip("'InlineArray' is only available in Swift 6.2 and later")
3979-
#endif // compiler(>=6.2)
3980-
}
3981-
39823935
func testByteBufferEncode() throws {
39833936
let encoder = JSONEncoder()
39843937
let hello = "Hello, world!"
@@ -4508,5 +4461,48 @@ extension ByteBufferTest {
45084461
let result = self.buf.readBytes(length: 4)
45094462
XCTAssertEqual(Array(0..<4), result!)
45104463
}
4464+
4465+
@available(macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26, *)
4466+
func testReadInlineArrayOfUInt8() throws {
4467+
let bytes = (0..<10).map { _ in UInt8.random(in: .min ... .max) }
4468+
4469+
let startWriterIndex = self.buf.writerIndex
4470+
let written = self.buf.writeBytes(bytes)
4471+
XCTAssertEqual(startWriterIndex + written, self.buf.writerIndex)
4472+
XCTAssertEqual(written, self.buf.readableBytes)
4473+
4474+
let result = try XCTUnwrap(
4475+
self.buf.readInlineArray(as: InlineArray<10, UInt8>.self)
4476+
)
4477+
XCTAssertEqual(10, result.count)
4478+
for idx in result.indices {
4479+
XCTAssertEqual(bytes[idx], result[idx])
4480+
}
4481+
XCTAssertEqual(0, self.buf.readableBytes)
4482+
XCTAssertEqual(10, self.buf.readerIndex)
4483+
}
4484+
4485+
@available(macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26, *)
4486+
func testReadInlineArrayOfUInt64() throws {
4487+
let bytes = (0..<10).map { _ in UInt64.random(in: .min ... .max) }
4488+
4489+
let startWriterIndex = self.buf.writerIndex
4490+
var written = 0
4491+
for byte in bytes {
4492+
written += self.buf.writeInteger(byte)
4493+
}
4494+
XCTAssertEqual(startWriterIndex + written, self.buf.writerIndex)
4495+
XCTAssertEqual(written, self.buf.readableBytes)
4496+
4497+
let result = try XCTUnwrap(
4498+
self.buf.readInlineArray(as: InlineArray<10, UInt64>.self)
4499+
)
4500+
XCTAssertEqual(10, result.count)
4501+
for idx in result.indices {
4502+
XCTAssertEqual(bytes[idx], result[idx])
4503+
}
4504+
XCTAssertEqual(0, self.buf.readableBytes)
4505+
XCTAssertEqual(80, self.buf.readerIndex)
4506+
}
45114507
}
45124508
#endif

0 commit comments

Comments
 (0)