Skip to content

Commit

Permalink
descriptive error message in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davedelong committed Oct 26, 2024
1 parent 27c1420 commit ef22dcb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Tests/TimeTests/XCTAssert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,55 @@ func XCTAssertEqualWithAccuracyWorkaround<FP: BinaryFloatingPoint>(_ value1: FP,
@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEEra>(_ time: Fixed<U>, era: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEYear>(_ time: Fixed<U>, era: Int, year: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEMonth>(_ time: Fixed<U>, era: Int, year: Int, month: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEDay>(_ time: Fixed<U>, era: Int, year: Int, month: Int, day: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month && time.day == day { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month), day=\(day)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month), day=\(day)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEHour>(_ time: Fixed<U>, era: Int, year: Int, month: Int, day: Int, hour: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month && time.day == day && time.hour == hour { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOEMinute>(_ time: Fixed<U>, era: Int, year: Int, month: Int, day: Int, hour: Int, minute: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month && time.day == day && time.hour == hour && time.minute == minute { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOESecond>(_ time: Fixed<U>, era: Int, year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month && time.day == day && time.hour == hour && time.minute == minute && time.second == second { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute), second=\(second)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute), second=\(second)", file: file, line: line)
return false
}

@discardableResult
func XCTAssertTime<U: StandardUnit & LTOENanosecond>(_ time: Fixed<U>, era: Int, year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, file: StaticString = #file, line: UInt = #line) -> Bool {
if time.era == era && time.year == year && time.month == month && time.day == day && time.hour == hour && time.minute == minute && time.second == second && time.nanosecond == nanosecond { return true }
XCTFail("Unexpected time components: \(time), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute), second=\(second), nanosecond=\(nanosecond)", file: file, line: line)
XCTFail("Unexpected time components: \(time.dateComponents), expecting era=\(era), year=\(year), month=\(month), day=\(day), hour=\(hour), minute=\(minute), second=\(second), nanosecond=\(nanosecond)", file: file, line: line)
return false
}

0 comments on commit ef22dcb

Please sign in to comment.