Skip to content

Commit fea84cf

Browse files
committed
Add test for NSUUID.description
1 parent 62d7528 commit fea84cf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Foundation/NSUUID.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
8080
public override var hash: Int {
8181
return Int(CFHashBytes(buffer, 16))
8282
}
83+
84+
public override var description: String {
85+
return UUIDString
86+
}
8387
}

TestFoundation/TestNSUUID.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class TestNSUUID : XCTestCase {
2525
("test_InvalidUUID", test_InvalidUUID),
2626
("test_InitializationWithNil", test_InitializationWithNil),
2727
("test_UUIDString", test_UUIDString),
28+
("test_description", test_description),
2829
]
2930
}
3031

@@ -53,4 +54,9 @@ class TestNSUUID : XCTestCase {
5354
let uuid = NSUUID(UUIDBytes: [0xe6,0x21,0xe1,0xf8,0xc3,0x6c,0x49,0x5a,0x93,0xfc,0x0c,0x24,0x7a,0x3e,0x6e,0x5f])
5455
XCTAssertEqual(uuid.UUIDString, "e621e1f8-c36c-495a-93fc-0c247a3e6e5f", "The UUIDString representation must be lowercase as defined by RFC 4122.")
5556
}
57+
58+
func test_description() {
59+
let uuid = NSUUID()
60+
XCTAssertEqual(uuid.description, uuid.UUIDString, "The description must be the same as the UUIDString.")
61+
}
5662
}

0 commit comments

Comments
 (0)