File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Tests/CustomDumpTests/Conformances Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,18 @@ public func customDump<T, TargetStream>(
5959
6060 var visitedItems : Set < ObjectIdentifier > = [ ]
6161
62- func customDumpHelp< TargetStream> (
63- _ value: Any ,
62+ func customDumpHelp< T , TargetStream> (
63+ _ value: T ,
6464 to target: inout TargetStream ,
6565 name: String ? ,
6666 indent: Int ,
6767 maxDepth: Int
6868 ) where TargetStream: TextOutputStream {
69+ if T . self is AnyObject . Type , withUnsafeBytes ( of: value, { $0. allSatisfy { $0 == 0 } } ) {
70+ target. write ( ( name. map { " \( $0) : " } ?? " " ) . appending ( " (null pointer) " ) . indenting ( by: indent) )
71+ return
72+ }
73+
6974 let mirror = Mirror ( customDumpReflecting: value)
7075 var out = " "
7176
Original file line number Diff line number Diff line change @@ -432,7 +432,7 @@ final class FoundationTests: XCTestCase {
432432 func testNSNumber( ) {
433433 var dump = " "
434434 customDump (
435- NSNumber ( booleanLiteral : true ) ,
435+ 1 as NSNumber ,
436436 to: & dump
437437 )
438438 XCTAssertNoDifference (
@@ -441,6 +441,20 @@ final class FoundationTests: XCTestCase {
441441 1
442442 """
443443 )
444+
445+ #if canImport(ObjectiveC)
446+ dump = " "
447+ customDump (
448+ NSNumber ( ) ,
449+ to: & dump
450+ )
451+ XCTAssertNoDifference (
452+ dump,
453+ """
454+ (null pointer)
455+ """
456+ )
457+ #endif
444458 }
445459
446460 func testNSOrderedSet( ) {
You can’t perform that action at this time.
0 commit comments