Skip to content

Commit ece2965

Browse files
committed
[test] check for availability before testing
- These tests verify updated behaviour of existing API, and should check for availability first.
1 parent 044f436 commit ece2965

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() }
@@ -270,6 +272,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
270272
}
271273

272274
CStringTests.test("String.cString.with.String.input") {
275+
guard #available(SwiftStdlib 5.7, *) else { return }
273276
let (u8p, dealloc) = getASCIIUTF8()
274277
defer { dealloc() }
275278
var str = String(cString: "ab")
@@ -283,6 +286,7 @@ CStringTests.test("String.cString.with.String.input") {
283286
}
284287

285288
CStringTests.test("String.cString.with.inout.UInt8.conversion") {
289+
guard #available(SwiftStdlib 5.7, *) else { return }
286290
var c = UInt8.zero
287291
var str = String(cString: &c)
288292
expectTrue(str.isEmpty)
@@ -296,6 +300,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
296300
}
297301

298302
CStringTests.test("String.cString.with.inout.CChar.conversion") {
303+
guard #available(SwiftStdlib 5.7, *) else { return }
299304
var c = CChar.zero
300305
var str = String(cString: &c)
301306
expectTrue(str.isEmpty)
@@ -309,6 +314,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
309314
}
310315

311316
CStringTests.test("String.validatingUTF8.with.Array.input") {
317+
guard #available(SwiftStdlib 5.7, *) else { return }
312318
do {
313319
let (u8p, dealloc) = getASCIIUTF8()
314320
defer { dealloc() }
@@ -332,6 +338,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
332338
}
333339

334340
CStringTests.test("String.validatingUTF8.with.String.input") {
341+
guard #available(SwiftStdlib 5.7, *) else { return }
335342
let (u8p, dealloc) = getASCIIUTF8()
336343
defer { dealloc() }
337344
var str = String(validatingUTF8: "ab")
@@ -347,6 +354,7 @@ CStringTests.test("String.validatingUTF8.with.String.input") {
347354
}
348355

349356
CStringTests.test("String.validatingUTF8.with.inout.conversion") {
357+
guard #available(SwiftStdlib 5.7, *) else { return }
350358
var c = CChar.zero
351359
var str = String(validatingUTF8: &c)
352360
expectNotNil(str)
@@ -361,6 +369,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
361369
}
362370

363371
CStringTests.test("String.decodeCString.with.Array.input") {
372+
guard #available(SwiftStdlib 5.7, *) else { return }
364373
do {
365374
let (u8p, dealloc) = getASCIIUTF8()
366375
defer { dealloc() }
@@ -385,6 +394,7 @@ CStringTests.test("String.decodeCString.with.Array.input") {
385394
}
386395

387396
CStringTests.test("String.decodeCString.with.String.input") {
397+
guard #available(SwiftStdlib 5.7, *) else { return }
388398
let (u8p, dealloc) = getASCIIUTF8()
389399
defer { dealloc() }
390400
var result = String.decodeCString(
@@ -404,6 +414,7 @@ CStringTests.test("String.decodeCString.with.String.input") {
404414
}
405415

406416
CStringTests.test("String.decodeCString.with.inout.conversion") {
417+
guard #available(SwiftStdlib 5.7, *) else { return }
407418
var c = Unicode.UTF8.CodeUnit.zero
408419
var result = String.decodeCString(
409420
&c, as: Unicode.UTF8.self, repairingInvalidCodeUnits: true
@@ -421,6 +432,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
421432
}
422433

423434
CStringTests.test("String.init.decodingCString.with.Array.input") {
435+
guard #available(SwiftStdlib 5.7, *) else { return }
424436
do {
425437
let (u8p, dealloc) = getASCIIUTF8()
426438
defer { dealloc() }
@@ -443,6 +455,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
443455
}
444456

445457
CStringTests.test("String.init.decodingCString.with.String.input") {
458+
guard #available(SwiftStdlib 5.7, *) else { return }
446459
let (u8p, dealloc) = getASCIIUTF8()
447460
defer { dealloc() }
448461
var str = String(decodingCString: "ab", as: Unicode.UTF8.self)
@@ -456,6 +469,7 @@ CStringTests.test("String.init.decodingCString.with.String.input") {
456469
}
457470

458471
CStringTests.test("String.init.decodingCString.with.inout.conversion") {
472+
guard #available(SwiftStdlib 5.7, *) else { return }
459473
var c = Unicode.UTF8.CodeUnit.zero
460474
var str = String(decodingCString: &c, as: Unicode.UTF8.self)
461475
expectEqual(str.isEmpty, true)

0 commit comments

Comments
 (0)