@@ -42,26 +42,27 @@ class TestDate : XCTestCase {
42
42
43
43
func test_BasicConstruction( ) {
44
44
let d = Date ( )
45
- XCTAssertNotNil ( d)
45
+ XCTAssert ( d. timeIntervalSince1970 != 0 )
46
+ XCTAssert ( d. timeIntervalSinceReferenceDate != 0 )
46
47
}
47
48
48
49
func test_descriptionWithLocale( ) {
49
50
let d = NSDate ( timeIntervalSince1970: 0 )
50
51
XCTAssertEqual ( d. description ( with: nil ) , " 1970-01-01 00:00:00 +0000 " )
51
- XCTAssertNotNil ( d. description ( with: Locale ( identifier: " ja_JP " ) ) )
52
+ XCTAssertFalse ( d. description ( with: Locale ( identifier: " ja_JP " ) ) . isEmpty )
52
53
}
53
54
54
55
func test_InitTimeIntervalSince1970( ) {
55
56
let ti : TimeInterval = 1
56
57
let d = Date ( timeIntervalSince1970: ti)
57
- XCTAssertNotNil ( d )
58
+ XCTAssert ( d . timeIntervalSince1970 == ti )
58
59
}
59
60
60
61
func test_InitTimeIntervalSinceSinceDate( ) {
61
62
let ti : TimeInterval = 1
62
63
let d1 = Date ( )
63
64
let d2 = Date ( timeInterval: ti, since: d1)
64
- XCTAssertNotNil ( d2)
65
+ XCTAssertNotNil ( d2. timeIntervalSince1970 == d1 . timeIntervalSince1970 + ti )
65
66
}
66
67
67
68
func test_TimeIntervalSinceSinceDate( ) {
@@ -73,19 +74,22 @@ class TestDate : XCTestCase {
73
74
74
75
func test_DistantFuture( ) {
75
76
let d = Date . distantFuture
76
- XCTAssertNotNil ( d)
77
+ let now = Date ( )
78
+ XCTAssertGreaterThan ( d, now)
77
79
}
78
80
79
81
func test_DistantPast( ) {
82
+ let now = Date ( )
80
83
let d = Date . distantPast
81
- XCTAssertNotNil ( d)
84
+
85
+ XCTAssertLessThan ( d, now)
82
86
}
83
87
84
88
func test_DateByAddingTimeInterval( ) {
85
89
let ti : TimeInterval = 1
86
90
let d1 = Date ( )
87
91
let d2 = d1 + ti
88
- XCTAssertNotNil ( d2)
92
+ XCTAssertNotNil ( d2. timeIntervalSince1970 == d1 . timeIntervalSince1970 + ti )
89
93
}
90
94
91
95
func test_EarlierDate( ) {
0 commit comments