Created
November 24, 2019 19:53
-
-
Save levibostian/65333090e37f0e63e87671611579cdcc to your computer and use it in GitHub Desktop.
XCTest extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import XCTest | |
extension XCTest { | |
func XCTAssertNewer(_ newer: Date, _ older: Date, file: StaticString = #file, line: UInt = #line) { | |
XCTAssertGreaterThan(newer.timeIntervalSince1970, older.timeIntervalSince1970, "\(newer) is *not* newer then \(older)", file: file, line: line) | |
} | |
func XCTAssertOlder(_ older: Date, _ newer: Date, file: StaticString = #file, line: UInt = #line) { | |
XCTAssertGreaterThan(older.timeIntervalSince1970, newer.timeIntervalSince1970, "\(older) is *not* older then \(newer)", file: file, line: line) | |
} | |
func XCTAssertEqualDate(_ one: Date, _ two: Date, file: StaticString = #file, line: UInt = #line) { | |
XCTAssertEqual(one.timeIntervalSinceReferenceDate, two.timeIntervalSinceReferenceDate, accuracy: 0.001, "\(one) is *not* equal to \(two)", file: file, line: line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment