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>(
282282 print ( value. indenting ( by: name != nil ? 2 : 0 ) , to: & out)
283283 out. write ( name != nil ? " \" \" \" \( hashes) " : " \" \" \" \( hashes) " )
284284 }
285- } else if value. contains ( " \" " ) {
285+ } else if value. contains ( " \" " ) || value . contains ( " \\ " ) {
286286 let hashes = String ( repeating: " # " , count: max ( value. hashCount ( isMultiline: false ) , 1 ) )
287287 out. write ( " \( hashes) \" \( value) \" \( hashes) " )
288288 } else {
Original file line number Diff line number Diff line change @@ -433,6 +433,27 @@ final class DumpTests: XCTestCase {
433433 dump,
434434 #####"####"This has a "### in it"####"#####
435435 )
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+ )
436457 }
437458
438459 func testMultilineString( ) {
You can’t perform that action at this time.
0 commit comments