|
17 | 17 | import SwiftXCTest
|
18 | 18 | #endif
|
19 | 19 |
|
| 20 | +private func assertEqual(_ lhs:PersonNameComponents, |
| 21 | + _ rhs: PersonNameComponents, |
| 22 | + file: StaticString = #file, |
| 23 | + line: UInt = #line) { |
| 24 | + assert(equal: true, lhs, rhs, file: file, line: line) |
| 25 | +} |
| 26 | + |
| 27 | +private func assertNotEqual(_ lhs:PersonNameComponents, |
| 28 | + _ rhs: PersonNameComponents, |
| 29 | + file: StaticString = #file, |
| 30 | + line: UInt = #line) { |
| 31 | + assert(equal: false, lhs, rhs, file: file, line: line) |
| 32 | +} |
20 | 33 |
|
| 34 | +private func assert(equal: Bool, |
| 35 | + _ lhs:PersonNameComponents, |
| 36 | + _ rhs: PersonNameComponents, |
| 37 | + file: StaticString = #file, |
| 38 | + line: UInt = #line) { |
| 39 | + if equal { |
| 40 | + XCTAssertEqual(lhs, rhs, file: file, line: line) |
| 41 | + XCTAssertEqual(lhs._bridgeToObjectiveC(), rhs._bridgeToObjectiveC(), file: file, line: line) |
| 42 | + XCTAssertTrue(lhs._bridgeToObjectiveC().isEqual(rhs), file: file, line: line) |
| 43 | + } else { |
| 44 | + XCTAssertNotEqual(lhs, rhs, file: file, line: line) |
| 45 | + XCTAssertNotEqual(lhs._bridgeToObjectiveC(), rhs._bridgeToObjectiveC(), file: file, line: line) |
| 46 | + XCTAssertFalse(lhs._bridgeToObjectiveC().isEqual(rhs), file: file, line: line) |
| 47 | + } |
| 48 | +} |
21 | 49 |
|
22 | 50 | class TestNSPersonNameComponents : XCTestCase {
|
23 | 51 |
|
@@ -66,54 +94,54 @@ class TestNSPersonNameComponents : XCTestCase {
|
66 | 94 | do {
|
67 | 95 | let lhs = PersonNameComponents()
|
68 | 96 | let rhs = PersonNameComponents()
|
69 |
| - XCTAssertEqual(lhs, rhs) |
| 97 | + assertEqual(lhs, rhs) |
70 | 98 | }
|
71 | 99 | do {
|
72 | 100 | let lhs = self.makePersonNameComponentsWithTestValues()
|
73 | 101 | let rhs = self.makePersonNameComponentsWithTestValues()
|
74 |
| - XCTAssertEqual(lhs, rhs) |
| 102 | + assertEqual(lhs, rhs) |
75 | 103 | }
|
76 | 104 | do {
|
77 | 105 | var lhs = self.makePersonNameComponentsWithTestValues()
|
78 | 106 | lhs.namePrefix = "differentValue"
|
79 | 107 | let rhs = self.makePersonNameComponentsWithTestValues()
|
80 |
| - XCTAssertNotEqual(lhs, rhs) |
| 108 | + assertNotEqual(lhs, rhs) |
81 | 109 | }
|
82 | 110 | do {
|
83 | 111 | var lhs = self.makePersonNameComponentsWithTestValues()
|
84 | 112 | lhs.givenName = "differentValue"
|
85 | 113 | let rhs = self.makePersonNameComponentsWithTestValues()
|
86 |
| - XCTAssertNotEqual(lhs, rhs) |
| 114 | + assertNotEqual(lhs, rhs) |
87 | 115 | }
|
88 | 116 | do {
|
89 | 117 | var lhs = self.makePersonNameComponentsWithTestValues()
|
90 | 118 | lhs.middleName = "differentValue"
|
91 | 119 | let rhs = self.makePersonNameComponentsWithTestValues()
|
92 |
| - XCTAssertNotEqual(lhs, rhs) |
| 120 | + assertNotEqual(lhs, rhs) |
93 | 121 | }
|
94 | 122 | do {
|
95 | 123 | var lhs = self.makePersonNameComponentsWithTestValues()
|
96 | 124 | lhs.familyName = "differentValue"
|
97 | 125 | let rhs = self.makePersonNameComponentsWithTestValues()
|
98 |
| - XCTAssertNotEqual(lhs, rhs) |
| 126 | + assertNotEqual(lhs, rhs) |
99 | 127 | }
|
100 | 128 | do {
|
101 | 129 | var lhs = self.makePersonNameComponentsWithTestValues()
|
102 | 130 | lhs.nameSuffix = "differentValue"
|
103 | 131 | let rhs = self.makePersonNameComponentsWithTestValues()
|
104 |
| - XCTAssertNotEqual(lhs, rhs) |
| 132 | + assertNotEqual(lhs, rhs) |
105 | 133 | }
|
106 | 134 | do {
|
107 | 135 | var lhs = self.makePersonNameComponentsWithTestValues()
|
108 | 136 | lhs.nickname = "differentValue"
|
109 | 137 | let rhs = self.makePersonNameComponentsWithTestValues()
|
110 |
| - XCTAssertNotEqual(lhs, rhs) |
| 138 | + assertNotEqual(lhs, rhs) |
111 | 139 | }
|
112 | 140 | do {
|
113 | 141 | var lhs = self.makePersonNameComponentsWithTestValues()
|
114 | 142 | lhs.phoneticRepresentation?.namePrefix = "differentValue"
|
115 | 143 | let rhs = self.makePersonNameComponentsWithTestValues()
|
116 |
| - XCTAssertNotEqual(lhs, rhs) |
| 144 | + assertNotEqual(lhs, rhs) |
117 | 145 | }
|
118 | 146 | }
|
119 | 147 | }
|
|
0 commit comments