@@ -239,9 +239,13 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239239 }
240240 }
241241 // no need to test every case; that is covered in other tests
242+ #if os(Linux)
243+ expectCrashLater ( )
244+ #else
242245 expectCrashLater (
243246 withMessage: " input of String.init(cString:) must be null-terminated "
244247 )
248+ #endif
245249 _ = String ( cString: [ ] as [ UInt8 ] )
246250 expectUnreachable ( )
247251}
@@ -260,9 +264,13 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
260264 }
261265 }
262266 // no need to test every case; that is covered in other tests
267+ #if os(Linux)
268+ expectCrashLater ( )
269+ #else
263270 expectCrashLater (
264271 withMessage: " input of String.init(cString:) must be null-terminated "
265272 )
273+ #endif
266274 _ = String ( cString: [ ] as [ CChar ] )
267275 expectUnreachable ( )
268276}
@@ -285,9 +293,13 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
285293 var str = String ( cString: & c)
286294 expectTrue ( str. isEmpty)
287295 c = 100
296+ #if os(Linux)
297+ expectCrashLater ( )
298+ #else
288299 expectCrashLater (
289300 withMessage: " input of String.init(cString:) must be null-terminated "
290301 )
302+ #endif
291303 str = String ( cString: & c)
292304 expectUnreachable ( )
293305}
@@ -297,9 +309,13 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
297309 var str = String ( cString: & c)
298310 expectTrue ( str. isEmpty)
299311 c = 100
312+ #if os(Linux)
313+ expectCrashLater ( )
314+ #else
300315 expectCrashLater (
301316 withMessage: " input of String.init(cString:) must be null-terminated "
302317 )
318+ #endif
303319 str = String ( cString: & c)
304320 expectUnreachable ( )
305321}
@@ -319,9 +335,13 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
319335 }
320336 }
321337 // no need to test every case; that is covered in other tests
338+ #if os(Linux)
339+ expectCrashLater ( )
340+ #else
322341 expectCrashLater (
323342 withMessage: " input of String.init(validatingUTF8:) must be null-terminated "
324343 )
344+ #endif
325345 _ = String ( validatingUTF8: [ ] )
326346 expectUnreachable ( )
327347}
@@ -347,9 +367,13 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
347367 expectNotNil ( str)
348368 expectEqual ( str? . isEmpty, true )
349369 c = 100
370+ #if os(Linux)
371+ expectCrashLater ( )
372+ #else
350373 expectCrashLater (
351374 withMessage: " input of String.init(validatingUTF8:) must be null-terminated "
352375 )
376+ #endif
353377 str = String ( validatingUTF8: & c)
354378 expectUnreachable ( )
355379}
@@ -370,9 +394,13 @@ CStringTests.test("String.decodeCString.with.Array.input") {
370394 }
371395 }
372396 // no need to test every case; that is covered in other tests
397+ #if os(Linux)
398+ expectCrashLater ( )
399+ #else
373400 expectCrashLater (
374401 withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
375402 )
403+ #endif
376404 _ = String . decodeCString ( [ ] , as: Unicode . UTF8. self)
377405 expectUnreachable ( )
378406}
@@ -405,9 +433,13 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
405433 expectEqual ( result? . result. isEmpty, true )
406434 expectEqual ( result? . repairsMade, false )
407435 c = 100
436+ #if os(Linux)
437+ expectCrashLater ( )
438+ #else
408439 expectCrashLater (
409440 withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
410441 )
442+ #endif
411443 result = String . decodeCString ( & c, as: Unicode . UTF8. self)
412444 expectUnreachable ( )
413445}
@@ -426,9 +458,13 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
426458 }
427459 }
428460 // no need to test every case; that is covered in other tests
461+ #if os(Linux)
462+ expectCrashLater ( )
463+ #else
429464 expectCrashLater (
430465 withMessage: " input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated "
431466 )
467+ #endif
432468 _ = String ( decodingCString: [ ] , as: Unicode . UTF8. self)
433469 expectUnreachable ( )
434470}
@@ -451,9 +487,13 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
451487 var str = String ( decodingCString: & c, as: Unicode . UTF8. self)
452488 expectEqual ( str. isEmpty, true )
453489 c = 100
490+ #if os(Linux)
491+ expectCrashLater ( )
492+ #else
454493 expectCrashLater (
455494 withMessage: " input of String.init(decodingCString:as:) must be null-terminated "
456495 )
496+ #endif
457497 str = String ( decodingCString: & c, as: Unicode . UTF8. self)
458498 expectUnreachable ( )
459499}
0 commit comments