@@ -42,26 +42,27 @@ class TestDate : XCTestCase {
4242
4343 func test_BasicConstruction( ) {
4444 let d = Date ( )
45- XCTAssertNotNil ( d)
45+ XCTAssert ( d. timeIntervalSince1970 != 0 )
46+ XCTAssert ( d. timeIntervalSinceReferenceDate != 0 )
4647 }
4748
4849 func test_descriptionWithLocale( ) {
4950 let d = NSDate ( timeIntervalSince1970: 0 )
5051 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 )
5253 }
5354
5455 func test_InitTimeIntervalSince1970( ) {
5556 let ti : TimeInterval = 1
5657 let d = Date ( timeIntervalSince1970: ti)
57- XCTAssertNotNil ( d )
58+ XCTAssert ( d . timeIntervalSince1970 == ti )
5859 }
5960
6061 func test_InitTimeIntervalSinceSinceDate( ) {
6162 let ti : TimeInterval = 1
6263 let d1 = Date ( )
6364 let d2 = Date ( timeInterval: ti, since: d1)
64- XCTAssertNotNil ( d2)
65+ XCTAssertNotNil ( d2. timeIntervalSince1970 == d1 . timeIntervalSince1970 + ti )
6566 }
6667
6768 func test_TimeIntervalSinceSinceDate( ) {
@@ -73,19 +74,22 @@ class TestDate : XCTestCase {
7374
7475 func test_DistantFuture( ) {
7576 let d = Date . distantFuture
76- XCTAssertNotNil ( d)
77+ let now = Date ( )
78+ XCTAssertGreaterThan ( d, now)
7779 }
7880
7981 func test_DistantPast( ) {
82+ let now = Date ( )
8083 let d = Date . distantPast
81- XCTAssertNotNil ( d)
84+
85+ XCTAssertLessThan ( d, now)
8286 }
8387
8488 func test_DateByAddingTimeInterval( ) {
8589 let ti : TimeInterval = 1
8690 let d1 = Date ( )
8791 let d2 = d1 + ti
88- XCTAssertNotNil ( d2)
92+ XCTAssertNotNil ( d2. timeIntervalSince1970 == d1 . timeIntervalSince1970 + ti )
8993 }
9094
9195 func test_EarlierDate( ) {
0 commit comments