@@ -239,9 +239,13 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239
239
}
240
240
}
241
241
// no need to test every case; that is covered in other tests
242
+ #if os(Linux)
243
+ expectCrashLater ( )
244
+ #else
242
245
expectCrashLater (
243
246
withMessage: " input of String.init(cString:) must be null-terminated "
244
247
)
248
+ #endif
245
249
_ = String ( cString: [ ] as [ UInt8 ] )
246
250
expectUnreachable ( )
247
251
}
@@ -260,9 +264,13 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
260
264
}
261
265
}
262
266
// no need to test every case; that is covered in other tests
267
+ #if os(Linux)
268
+ expectCrashLater ( )
269
+ #else
263
270
expectCrashLater (
264
271
withMessage: " input of String.init(cString:) must be null-terminated "
265
272
)
273
+ #endif
266
274
_ = String ( cString: [ ] as [ CChar ] )
267
275
expectUnreachable ( )
268
276
}
@@ -285,9 +293,13 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
285
293
var str = String ( cString: & c)
286
294
expectTrue ( str. isEmpty)
287
295
c = 100
296
+ #if os(Linux)
297
+ expectCrashLater ( )
298
+ #else
288
299
expectCrashLater (
289
300
withMessage: " input of String.init(cString:) must be null-terminated "
290
301
)
302
+ #endif
291
303
str = String ( cString: & c)
292
304
expectUnreachable ( )
293
305
}
@@ -297,9 +309,13 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
297
309
var str = String ( cString: & c)
298
310
expectTrue ( str. isEmpty)
299
311
c = 100
312
+ #if os(Linux)
313
+ expectCrashLater ( )
314
+ #else
300
315
expectCrashLater (
301
316
withMessage: " input of String.init(cString:) must be null-terminated "
302
317
)
318
+ #endif
303
319
str = String ( cString: & c)
304
320
expectUnreachable ( )
305
321
}
@@ -319,9 +335,13 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
319
335
}
320
336
}
321
337
// no need to test every case; that is covered in other tests
338
+ #if os(Linux)
339
+ expectCrashLater ( )
340
+ #else
322
341
expectCrashLater (
323
342
withMessage: " input of String.init(validatingUTF8:) must be null-terminated "
324
343
)
344
+ #endif
325
345
_ = String ( validatingUTF8: [ ] )
326
346
expectUnreachable ( )
327
347
}
@@ -347,9 +367,13 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
347
367
expectNotNil ( str)
348
368
expectEqual ( str? . isEmpty, true )
349
369
c = 100
370
+ #if os(Linux)
371
+ expectCrashLater ( )
372
+ #else
350
373
expectCrashLater (
351
374
withMessage: " input of String.init(validatingUTF8:) must be null-terminated "
352
375
)
376
+ #endif
353
377
str = String ( validatingUTF8: & c)
354
378
expectUnreachable ( )
355
379
}
@@ -370,9 +394,13 @@ CStringTests.test("String.decodeCString.with.Array.input") {
370
394
}
371
395
}
372
396
// no need to test every case; that is covered in other tests
397
+ #if os(Linux)
398
+ expectCrashLater ( )
399
+ #else
373
400
expectCrashLater (
374
401
withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
375
402
)
403
+ #endif
376
404
_ = String . decodeCString ( [ ] , as: Unicode . UTF8. self)
377
405
expectUnreachable ( )
378
406
}
@@ -405,9 +433,13 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
405
433
expectEqual ( result? . result. isEmpty, true )
406
434
expectEqual ( result? . repairsMade, false )
407
435
c = 100
436
+ #if os(Linux)
437
+ expectCrashLater ( )
438
+ #else
408
439
expectCrashLater (
409
440
withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
410
441
)
442
+ #endif
411
443
result = String . decodeCString ( & c, as: Unicode . UTF8. self)
412
444
expectUnreachable ( )
413
445
}
@@ -426,9 +458,13 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
426
458
}
427
459
}
428
460
// no need to test every case; that is covered in other tests
461
+ #if os(Linux)
462
+ expectCrashLater ( )
463
+ #else
429
464
expectCrashLater (
430
465
withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
431
466
)
467
+ #endif
432
468
_ = String ( decodingCString: [ ] , as: Unicode . UTF8. self)
433
469
expectUnreachable ( )
434
470
}
@@ -451,9 +487,13 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
451
487
var str = String ( decodingCString: & c, as: Unicode . UTF8. self)
452
488
expectEqual ( str. isEmpty, true )
453
489
c = 100
490
+ #if os(Linux)
491
+ expectCrashLater ( )
492
+ #else
454
493
expectCrashLater (
455
494
withMessage: " input of String.init(decodingCString:as:) must be null-terminated "
456
495
)
496
+ #endif
457
497
str = String ( decodingCString: & c, as: Unicode . UTF8. self)
458
498
expectUnreachable ( )
459
499
}
0 commit comments