File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,8 @@ open class Host: NSObject {
75
75
}
76
76
77
77
open func isEqual( to aHost: Host ) -> Bool {
78
- return false
78
+ if self === aHost { return true }
79
+ return addresses. firstIndex { aHost. addresses. contains ( $0) } != nil
79
80
}
80
81
81
82
internal func _resolveCurrent( ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class TestHost: XCTestCase {
12
12
static var allTests : [ ( String , ( TestHost ) -> ( ) throws -> Void ) ] {
13
13
return [
14
14
( " test_addressesDoNotGrow " , test_addressesDoNotGrow) ,
15
+ ( " test_isEqual " , test_isEqual)
15
16
]
16
17
}
17
18
@@ -32,5 +33,21 @@ class TestHost: XCTestCase {
32
33
let swiftAddressesSecond = swift. addresses
33
34
XCTAssertEqual ( swiftAddressesSecond. count, swiftAddressesFirst. count)
34
35
}
36
+
37
+ func test_isEqual( ) {
38
+ let host0 = Host ( address: " 8.8.8.8 " )
39
+ let host1 = Host ( address: " 8.8.8.8 " )
40
+ XCTAssertTrue ( host0. isEqual ( to: host1) )
41
+
42
+ let host2 = Host ( address: " 8.8.8.9 " )
43
+ XCTAssertFalse ( host0. isEqual ( to: host2) )
44
+
45
+ let swift0 = Host ( name: " swift.org " )
46
+ let swift1 = Host ( name: " swift.org " )
47
+ XCTAssertTrue ( swift0. isEqual ( to: swift1) )
48
+
49
+ let google = Host ( name: " google.com " )
50
+ XCTAssertFalse ( swift0. isEqual ( to: google) )
51
+ }
35
52
}
36
53
You can’t perform that action at this time.
0 commit comments