@@ -1315,9 +1315,11 @@ class ByteBufferTest: XCTestCase {
1315
1315
XCTAssertEqual ( " a " , buf. readString ( length: 1 ) )
1316
1316
}
1317
1317
1318
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
1319
1318
func testReadUTF8ValidatedString( ) throws {
1320
1319
#if compiler(>=6)
1320
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
1321
+ throw XCTSkip ( " 'readUTF8ValidatedString' is only available in Swift 6 and later " )
1322
+ }
1321
1323
buf. clear ( )
1322
1324
let expected = " hello "
1323
1325
buf. writeString ( expected)
@@ -1330,9 +1332,11 @@ class ByteBufferTest: XCTestCase {
1330
1332
#endif // compiler(>=6)
1331
1333
}
1332
1334
1333
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
1334
1335
func testGetUTF8ValidatedString( ) throws {
1335
1336
#if compiler(>=6)
1337
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
1338
+ throw XCTSkip ( " 'getUTF8ValidatedString' is only available in Swift 6 and later " )
1339
+ }
1336
1340
buf. clear ( )
1337
1341
let expected = " hello, goodbye "
1338
1342
buf. writeString ( expected)
@@ -1343,9 +1347,11 @@ class ByteBufferTest: XCTestCase {
1343
1347
#endif // compiler(>=6)
1344
1348
}
1345
1349
1346
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
1347
1350
func testReadUTF8InvalidString( ) throws {
1348
1351
#if compiler(>=6)
1352
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
1353
+ throw XCTSkip ( " 'readUTF8ValidatedString' is only available in Swift 6 and later " )
1354
+ }
1349
1355
buf. clear ( )
1350
1356
buf. writeBytes ( [ UInt8] ( repeating: 255 , count: 16 ) )
1351
1357
XCTAssertThrowsError ( try buf. readUTF8ValidatedString ( length: 16 ) ) { error in
@@ -4222,8 +4228,10 @@ extension ByteBufferTest {
4222
4228
// MARK: - peekUTF8ValidatedString Tests (available in Swift 6+)
4223
4229
4224
4230
#if compiler(>=6)
4225
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
4226
4231
func testPeekUTF8ValidatedString_Normal( ) throws {
4232
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
4233
+ throw XCTSkip ( " 'peekUTF8ValidatedString' is only available in Swift 6 and later " )
4234
+ }
4227
4235
var buffer = ByteBuffer ( )
4228
4236
let testString = " UTF8 Validated "
4229
4237
let written = buffer. writeString ( testString)
@@ -4232,17 +4240,21 @@ extension ByteBufferTest {
4232
4240
XCTAssertEqual ( buffer. readerIndex, 0 , " Reader index should remain unchanged. " )
4233
4241
}
4234
4242
4235
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
4236
4243
func testPeekUTF8ValidatedString_Empty( ) throws {
4244
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
4245
+ throw XCTSkip ( " 'peekUTF8ValidatedString' is only available in Swift 6 and later " )
4246
+ }
4237
4247
var buffer = ByteBuffer ( )
4238
4248
_ = buffer. writeString ( " " )
4239
4249
let peeked = try buffer. peekUTF8ValidatedString ( length: 0 )
4240
4250
XCTAssertEqual ( peeked, " " , " peekUTF8ValidatedString() should return an empty string when no bytes are written. " )
4241
4251
XCTAssertEqual ( buffer. readerIndex, 0 , " Reader index should remain unchanged for empty peek. " )
4242
4252
}
4243
4253
4244
- @available ( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * )
4245
4254
func testPeekUTF8ValidatedString_Repeated( ) throws {
4255
+ guard #available( macOS 15 , iOS 18 , tvOS 18 , watchOS 11 , * ) else {
4256
+ throw XCTSkip ( " 'peekUTF8ValidatedString' is only available in Swift 6 and later " )
4257
+ }
4246
4258
var buffer = ByteBuffer ( )
4247
4259
let testString = " Repeat UTF8 "
4248
4260
let written = buffer. writeString ( testString)
0 commit comments