diff --git a/Clocker/ClockerUnitTests/ClockerUnitTests.swift b/Clocker/ClockerUnitTests/ClockerUnitTests.swift index 208e309..49b190c 100644 --- a/Clocker/ClockerUnitTests/ClockerUnitTests.swift +++ b/Clocker/ClockerUnitTests/ClockerUnitTests.swift @@ -109,8 +109,12 @@ class ClockerUnitTests: XCTestCase { } func testDecoding() { - let timezone = TimezoneData.customObject(from: nil) - XCTAssertNotNil(timezone) + let timezone1 = TimezoneData.customObject(from: nil) + XCTAssertNotNil(timezone1) + + let data = Data() + let timezone2 = TimezoneData.customObject(from: data) + XCTAssertNil(timezone2) } func testDescription() { @@ -118,6 +122,12 @@ class ClockerUnitTests: XCTestCase { XCTAssertFalse(timezoneData.description.isEmpty) XCTAssertFalse(timezoneData.debugDescription.isEmpty) } + + func testHashing() { + let timezoneData = TimezoneData(with: california) + let hash = timezoneData.hash + XCTAssert(hash != -1) + } func testDeletingATimezone() { let defaults = UserDefaults.standard @@ -286,7 +296,7 @@ class ClockerUnitTests: XCTestCase { XCTAssertFalse(dataObject.shouldShowSeconds(88)) } - func testTimezone() { + func testTimezoneRetrieval() { let dataObject = TimezoneData(with: mumbai) XCTAssertEqual(dataObject.timezone(), "Asia/Calcutta") @@ -294,7 +304,6 @@ class ClockerUnitTests: XCTestCase { dataObject.isSystemTimezone = true let autoupdatingTimezone = TimeZone.autoupdatingCurrent.identifier XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone) - } func testFormattedLabel() { diff --git a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift index d2545e5..594a983 100644 --- a/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift +++ b/Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift @@ -277,7 +277,7 @@ public class TimezoneData: NSObject, NSCoding { } static func == (lhs: TimezoneData, rhs: TimezoneData) -> Bool { - return lhs.placeID == rhs.placeID + return lhs.isEqual(rhs) } public override func isEqual(_ object: Any?) -> Bool { diff --git a/Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift b/Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift index a143140..4da2c46 100644 --- a/Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift +++ b/Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift @@ -14,7 +14,8 @@ class TimezoneDataEqualityTests: XCTestCase { timezone2.timezoneID = "Africa/Banjul" timezone2.formattedAddress = "SameLabel" - XCTAssertNotEqual(timezone1, timezone2) + XCTAssertFalse(timezone1 == timezone2) // Test == + XCTAssertNotEqual(timezone1, timezone2) // Test isEqual } func testEqualityWhenTimezonesLabelsDiffer() { @@ -26,6 +27,7 @@ class TimezoneDataEqualityTests: XCTestCase { timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier timezone2.formattedAddress = "DifferentLabel" + XCTAssertFalse(timezone1 == timezone2) XCTAssertNotEqual(timezone1, timezone2) } @@ -40,6 +42,7 @@ class TimezoneDataEqualityTests: XCTestCase { timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier timezone2.formattedAddress = "DifferentLabel" + XCTAssertTrue(timezone1 == timezone2) XCTAssertEqual(timezone1, timezone2) } @@ -54,6 +57,7 @@ class TimezoneDataEqualityTests: XCTestCase { timezone2.timezoneID = TimeZone.autoupdatingCurrent.identifier timezone2.formattedAddress = "DifferentLabel" + XCTAssertFalse(timezone1 == timezone2) XCTAssertNotEqual(timezone1, timezone2) } }