Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianKienle committed Jul 3, 2020
1 parent 4fe1f69 commit 60690e8
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,26 @@ final class TracingStatusHistoryTests: XCTestCase {
XCTAssertEqual(history.countEnabledHours(since: now), 24 * 2)
XCTAssertEqual(history.countEnabledDays(since: now), 2)
}

func testNumberOfDays_Rounding() {
let now = Date()

var history: TracingStatusHistory = [
.init(on: true, date: now.addingTimeInterval(.init(hours: -((24 * 5) + 4))))
]

XCTAssertEqual(history.countEnabledDays(since: now), 5)

history = [
.init(on: true, date: now.addingTimeInterval(.init(hours: -((24 * 5) + 13))))
]
XCTAssertEqual(history.countEnabledDays(since: now), 6)

history = [
.init(on: true, date: now.addingTimeInterval(.init(hours: -((24 * 5) + 0))))
]
XCTAssertEqual(history.countEnabledDays(since: now), 5)
}
}

private extension TimeInterval {
Expand Down

0 comments on commit 60690e8

Please sign in to comment.