Skip to content

Implement Host.isEqual and Test #2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ open class Host: NSObject {
}

open func isEqual(to aHost: Host) -> Bool {
return false
return aHost._addresses == _addresses && aHost._info == _info && aHost._names == _names && aHost._resolved == _resolved && aHost._type == _type
}

internal func _resolveCurrent() {
Expand Down
14 changes: 14 additions & 0 deletions TestFoundation/TestHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class TestHost: XCTestCase {
static var allTests: [(String, (TestHost) -> () throws -> Void)] {
return [
("test_addressesDoNotGrow", test_addressesDoNotGrow),
("test_isEqual_positive", test_isEqual_positive),
("test_isEqual_negative", test_isEqual_negative)
]
}

Expand All @@ -32,5 +34,17 @@ class TestHost: XCTestCase {
let swiftAddressesSecond = swift.addresses
XCTAssertEqual(swiftAddressesSecond.count, swiftAddressesFirst.count)
}

func test_isEqual_positive() {
let host0 = Host(address: "8.8.8.8")
let host1 = Host(address: "8.8.8.8")
XCTAssertTrue(host0.isEqual(to: host1))
}

func test_isEqual_negative() {
let host0 = Host(address: "8.8.8.8")
let host1 = Host(address: "8.8.8.9")
XCTAssertFalse(host0.isEqual(to: host1))
}
}