7
7
8
8
import StdlibUnittest
9
9
10
+ #if arch(wasm32)
11
+ let enableCrashTests = false
12
+ #else
13
+ let enableCrashTests = true
14
+ #endif
15
+
10
16
var CStringTests = TestSuite ( " CStringTests " )
11
17
12
18
func getNullUTF8( ) -> UnsafeMutablePointer < UInt8 > ? {
@@ -227,6 +233,7 @@ CStringTests.test("Substring.withCString") {
227
233
228
234
CStringTests . test ( " String.cString.with.Array.UInt8.input " ) {
229
235
guard #available( SwiftStdlib 5 . 7 , * ) else { return }
236
+
230
237
do {
231
238
let ( u8p, dealloc) = getASCIIUTF8 ( )
232
239
defer { dealloc ( ) }
@@ -239,6 +246,7 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239
246
}
240
247
}
241
248
}
249
+ guard enableCrashTests else { return }
242
250
// no need to test every case; that is covered in other tests
243
251
expectCrashLater (
244
252
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
@@ -263,6 +271,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
263
271
}
264
272
}
265
273
}
274
+ guard enableCrashTests else { return }
266
275
// no need to test every case; that is covered in other tests
267
276
expectCrashLater (
268
277
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
@@ -292,6 +301,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
292
301
var str = String ( cString: & c)
293
302
expectTrue ( str. isEmpty)
294
303
c = 100
304
+ guard enableCrashTests else { return }
295
305
expectCrashLater (
296
306
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
297
307
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -306,6 +316,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
306
316
var str = String ( cString: & c)
307
317
expectTrue ( str. isEmpty)
308
318
c = 100
319
+ guard enableCrashTests else { return }
309
320
expectCrashLater (
310
321
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
311
322
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -330,6 +341,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
330
341
}
331
342
}
332
343
}
344
+ guard enableCrashTests else { return }
333
345
// no need to test every case; that is covered in other tests
334
346
expectCrashLater (
335
347
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
@@ -362,6 +374,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
362
374
expectNotNil ( str)
363
375
expectEqual ( str? . isEmpty, true )
364
376
c = 100
377
+ guard enableCrashTests else { return }
365
378
expectCrashLater (
366
379
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
367
380
// withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
@@ -387,6 +400,7 @@ CStringTests.test("String.decodeCString.with.Array.input") {
387
400
}
388
401
}
389
402
}
403
+ guard enableCrashTests else { return }
390
404
// no need to test every case; that is covered in other tests
391
405
expectCrashLater (
392
406
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
@@ -426,6 +440,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
426
440
expectEqual ( result? . result. isEmpty, true )
427
441
expectEqual ( result? . repairsMade, false )
428
442
c = 100
443
+ guard enableCrashTests else { return }
429
444
expectCrashLater (
430
445
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
431
446
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
@@ -449,6 +464,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
449
464
}
450
465
}
451
466
}
467
+ guard enableCrashTests else { return }
452
468
// no need to test every case; that is covered in other tests
453
469
expectCrashLater (
454
470
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
@@ -478,6 +494,7 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
478
494
var str = String ( decodingCString: & c, as: Unicode . UTF8. self)
479
495
expectEqual ( str. isEmpty, true )
480
496
c = 100
497
+ guard enableCrashTests else { return }
481
498
expectCrashLater (
482
499
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
483
500
// withMessage: "input of String.init(decodingCString:as:) must be null-terminated"
0 commit comments