-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathDispatchDate.swift
42 lines (30 loc) · 1.42 KB
/
DispatchDate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: libdispatch
// REQUIRES: foundation
import Dispatch
import Foundation
import StdlibUnittest
var DispatchAPI = TestSuite("DispatchAPI")
DispatchAPI.test("DispatchTime.addSubtractDateConstants") {
var then = DispatchTime.now() + Date.distantFuture.timeIntervalSinceNow
expectEqual(DispatchTime(uptimeNanoseconds: UInt64.max), then)
then = DispatchTime.now() + Date.distantPast.timeIntervalSinceNow
expectEqual(DispatchTime(uptimeNanoseconds: 1), then)
then = DispatchTime.now() - Date.distantFuture.timeIntervalSinceNow
expectEqual(DispatchTime(uptimeNanoseconds: 1), then)
then = DispatchTime.now() - Date.distantPast.timeIntervalSinceNow
expectEqual(DispatchTime(uptimeNanoseconds: UInt64.max), then)
}
DispatchAPI.test("DispatchWallTime.addSubtractDateConstants") {
let distantPastRawValue = DispatchWallTime.distantFuture.rawValue - UInt64(1)
var then = DispatchWallTime.now() + Date.distantFuture.timeIntervalSinceNow
expectEqual(DispatchWallTime.distantFuture, then)
then = DispatchWallTime.now() + Date.distantPast.timeIntervalSinceNow
expectEqual(distantPastRawValue, then.rawValue)
then = DispatchWallTime.now() - Date.distantFuture.timeIntervalSinceNow
expectEqual(distantPastRawValue, then.rawValue)
then = DispatchWallTime.now() - Date.distantPast.timeIntervalSinceNow
expectEqual(DispatchWallTime.distantFuture, then)
}
runAllTests()