File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ func _customDump<T, TargetStream>(
282
282
print ( value. indenting ( by: name != nil ? 2 : 0 ) , to: & out)
283
283
out. write ( name != nil ? " \" \" \" \( hashes) " : " \" \" \" \( hashes) " )
284
284
}
285
- } else if value. contains ( " \" " ) {
285
+ } else if value. contains ( " \" " ) || value . contains ( " \\ " ) {
286
286
let hashes = String ( repeating: " # " , count: max ( value. hashCount ( isMultiline: false ) , 1 ) )
287
287
out. write ( " \( hashes) \" \( value) \" \( hashes) " )
288
288
} else {
Original file line number Diff line number Diff line change @@ -433,6 +433,27 @@ final class DumpTests: XCTestCase {
433
433
dump,
434
434
#####"####"This has a "### in it"####"#####
435
435
)
436
+
437
+ dump = " "
438
+ customDump ( " This has a \\ in it " , to: & dump)
439
+ XCTAssertNoDifference (
440
+ dump,
441
+ ##"#"This has a \ in it"#"##
442
+ )
443
+
444
+ dump = " "
445
+ customDump ( " This has no special characters in it " , to: & dump)
446
+ XCTAssertNoDifference (
447
+ dump,
448
+ " \" This has no special characters in it \" "
449
+ )
450
+
451
+ dump = " "
452
+ customDump ( " This has a \t in it " , to: & dump)
453
+ XCTAssertNoDifference (
454
+ dump,
455
+ " \" This has a \\ t in it \" "
456
+ )
436
457
}
437
458
438
459
func testMultilineString( ) {
You can’t perform that action at this time.
0 commit comments