Skip to content

Instantly share code, notes, and snippets.

@levibostian
Created November 24, 2019 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levibostian/65333090e37f0e63e87671611579cdcc to your computer and use it in GitHub Desktop.
Save levibostian/65333090e37f0e63e87671611579cdcc to your computer and use it in GitHub Desktop.
XCTest extensions
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