Skip to content

Commit a7edd60

Browse files
authored
Merge pull request #42287 from glessard/rdar90336023
[test] check for availability before testing
2 parents b538e4f + f4533d4 commit a7edd60

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/stdlib/StringAPICString.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ CStringTests.test("Substring.withCString") {
226226
}
227227

228228
CStringTests.test("String.cString.with.Array.UInt8.input") {
229+
guard #available(SwiftStdlib 5.7, *) else { return }
229230
do {
230231
let (u8p, dealloc) = getASCIIUTF8()
231232
defer { dealloc() }
@@ -248,6 +249,7 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
248249
}
249250

250251
CStringTests.test("String.cString.with.Array.CChar.input") {
252+
guard #available(SwiftStdlib 5.7, *) else { return }
251253
do {
252254
let (u8p, dealloc) = getASCIIUTF8()
253255
defer { dealloc() }
@@ -271,6 +273,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
271273
}
272274

273275
CStringTests.test("String.cString.with.String.input") {
276+
guard #available(SwiftStdlib 5.7, *) else { return }
274277
let (u8p, dealloc) = getASCIIUTF8()
275278
defer { dealloc() }
276279
var str = String(cString: "ab")
@@ -284,6 +287,7 @@ CStringTests.test("String.cString.with.String.input") {
284287
}
285288

286289
CStringTests.test("String.cString.with.inout.UInt8.conversion") {
290+
guard #available(SwiftStdlib 5.7, *) else { return }
287291
var c = UInt8.zero
288292
var str = String(cString: &c)
289293
expectTrue(str.isEmpty)
@@ -297,6 +301,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
297301
}
298302

299303
CStringTests.test("String.cString.with.inout.CChar.conversion") {
304+
guard #available(SwiftStdlib 5.7, *) else { return }
300305
var c = CChar.zero
301306
var str = String(cString: &c)
302307
expectTrue(str.isEmpty)
@@ -310,6 +315,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
310315
}
311316

312317
CStringTests.test("String.validatingUTF8.with.Array.input") {
318+
guard #available(SwiftStdlib 5.7, *) else { return }
313319
do {
314320
let (u8p, dealloc) = getASCIIUTF8()
315321
defer { dealloc() }
@@ -334,6 +340,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
334340
}
335341

336342
CStringTests.test("String.validatingUTF8.with.String.input") {
343+
guard #available(SwiftStdlib 5.7, *) else { return }
337344
let (u8p, dealloc) = getASCIIUTF8()
338345
defer { dealloc() }
339346
var str = String(validatingUTF8: "ab")
@@ -349,6 +356,7 @@ CStringTests.test("String.validatingUTF8.with.String.input") {
349356
}
350357

351358
CStringTests.test("String.validatingUTF8.with.inout.conversion") {
359+
guard #available(SwiftStdlib 5.7, *) else { return }
352360
var c = CChar.zero
353361
var str = String(validatingUTF8: &c)
354362
expectNotNil(str)
@@ -363,6 +371,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
363371
}
364372

365373
CStringTests.test("String.decodeCString.with.Array.input") {
374+
guard #available(SwiftStdlib 5.7, *) else { return }
366375
do {
367376
let (u8p, dealloc) = getASCIIUTF8()
368377
defer { dealloc() }
@@ -388,6 +397,7 @@ CStringTests.test("String.decodeCString.with.Array.input") {
388397
}
389398

390399
CStringTests.test("String.decodeCString.with.String.input") {
400+
guard #available(SwiftStdlib 5.7, *) else { return }
391401
let (u8p, dealloc) = getASCIIUTF8()
392402
defer { dealloc() }
393403
var result = String.decodeCString(
@@ -407,6 +417,7 @@ CStringTests.test("String.decodeCString.with.String.input") {
407417
}
408418

409419
CStringTests.test("String.decodeCString.with.inout.conversion") {
420+
guard #available(SwiftStdlib 5.7, *) else { return }
410421
var c = Unicode.UTF8.CodeUnit.zero
411422
var result = String.decodeCString(
412423
&c, as: Unicode.UTF8.self, repairingInvalidCodeUnits: true
@@ -424,6 +435,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
424435
}
425436

426437
CStringTests.test("String.init.decodingCString.with.Array.input") {
438+
guard #available(SwiftStdlib 5.7, *) else { return }
427439
do {
428440
let (u8p, dealloc) = getASCIIUTF8()
429441
defer { dealloc() }
@@ -447,6 +459,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
447459
}
448460

449461
CStringTests.test("String.init.decodingCString.with.String.input") {
462+
guard #available(SwiftStdlib 5.7, *) else { return }
450463
let (u8p, dealloc) = getASCIIUTF8()
451464
defer { dealloc() }
452465
var str = String(decodingCString: "ab", as: Unicode.UTF8.self)
@@ -460,6 +473,7 @@ CStringTests.test("String.init.decodingCString.with.String.input") {
460473
}
461474

462475
CStringTests.test("String.init.decodingCString.with.inout.conversion") {
476+
guard #available(SwiftStdlib 5.7, *) else { return }
463477
var c = Unicode.UTF8.CodeUnit.zero
464478
var str = String(decodingCString: &c, as: Unicode.UTF8.self)
465479
expectEqual(str.isEmpty, true)

0 commit comments

Comments
 (0)