10
10
class TestDateInterval : XCTestCase {
11
11
static var allTests : [ ( String , ( TestDateInterval ) -> ( ) throws -> Void ) ] {
12
12
return [
13
- ( " test_defaultConstructor " , test_defaultConstructor ) ,
14
- ( " test_startEndConstructor " , test_startEndConstructor ) ,
15
- ( " test_startDurationConstructor " , test_startDurationConstructor ) ,
13
+ ( " test_defaultInitializer " , test_defaultInitializer ) ,
14
+ ( " test_startEndInitializer " , test_startEndInitializer ) ,
15
+ ( " test_startDurationInitializer " , test_startDurationInitializer ) ,
16
16
( " test_compareDifferentStarts " , test_compareDifferentStarts) ,
17
17
( " test_compareDifferentDurations " , test_compareDifferentDurations) ,
18
18
( " test_compareSame " , test_compareSame) ,
@@ -26,19 +26,19 @@ class TestDateInterval: XCTestCase {
26
26
]
27
27
}
28
28
29
- func test_defaultConstructor ( ) {
29
+ func test_defaultInitializer ( ) {
30
30
let dateInterval = DateInterval ( )
31
31
XCTAssertEqual ( dateInterval. duration, 0 )
32
32
}
33
-
34
- func test_startEndConstructor ( ) {
33
+
34
+ func test_startEndInitializer ( ) {
35
35
let date1 = dateWithString ( " 2019-04-04 17:09:23 -0700 " )
36
36
let date2 = dateWithString ( " 2019-04-04 18:09:23 -0700 " )
37
37
let dateInterval = DateInterval ( start: date1, end: date2)
38
38
XCTAssertEqual ( dateInterval. duration, 60 * 60 )
39
39
}
40
40
41
- func test_startDurationConstructor ( ) {
41
+ func test_startDurationInitializer ( ) {
42
42
let date = dateWithString ( " 2019-04-04 17:09:23 -0700 " )
43
43
let dateInterval = DateInterval ( start: date, duration: 60 )
44
44
XCTAssertEqual ( dateInterval. duration, 60 )
@@ -52,7 +52,7 @@ class TestDateInterval: XCTestCase {
52
52
XCTAssertEqual ( dateInterval1. compare ( dateInterval2) , . orderedAscending)
53
53
XCTAssertEqual ( dateInterval2. compare ( dateInterval1) , . orderedDescending)
54
54
}
55
-
55
+
56
56
func test_compareDifferentDurations( ) {
57
57
let date = dateWithString ( " 2019-04-04 17:09:23 -0700 " )
58
58
let dateInterval1 = DateInterval ( start: date, duration: 60 )
@@ -68,7 +68,7 @@ class TestDateInterval: XCTestCase {
68
68
XCTAssertEqual ( dateInterval1. compare ( dateInterval2) , . orderedSame)
69
69
XCTAssertEqual ( dateInterval2. compare ( dateInterval1) , . orderedSame)
70
70
}
71
-
71
+
72
72
func test_comparisonOperators( ) {
73
73
let date1 = dateWithString ( " 2019-04-04 17:00:00 -0700 " )
74
74
let date2 = dateWithString ( " 2019-04-04 17:30:00 -0700 " )
@@ -88,7 +88,7 @@ class TestDateInterval: XCTestCase {
88
88
let dateInterval2 = DateInterval ( start: date2, duration: 15 )
89
89
XCTAssertTrue ( dateInterval1. intersects ( dateInterval2) )
90
90
}
91
-
91
+
92
92
func test_intersection( ) {
93
93
let date1 = dateWithString ( " 2019-04-04 17:00:00 -0700 " )
94
94
let date2 = dateWithString ( " 2019-04-04 17:15:00 -0700 " )
@@ -108,15 +108,15 @@ class TestDateInterval: XCTestCase {
108
108
XCTAssertNotNil ( intersection)
109
109
XCTAssertEqual ( intersection!. duration, 0 )
110
110
}
111
-
111
+
112
112
func test_intersectionNil( ) {
113
113
let date1 = dateWithString ( " 2019-04-04 17:00:00 -0700 " )
114
114
let date2 = dateWithString ( " 2019-04-04 17:30:01 -0700 " )
115
115
let dateInterval1 = DateInterval ( start: date1, duration: 60 * 30 )
116
116
let dateInterval2 = DateInterval ( start: date2, duration: 60 * 30 )
117
117
XCTAssertNil ( dateInterval1. intersection ( with: dateInterval2) )
118
118
}
119
-
119
+
120
120
func test_contains( ) {
121
121
let date1 = dateWithString ( " 2019-04-04 17:00:00 -0700 " )
122
122
let date2 = dateWithString ( " 2019-04-04 17:30:00 -0700 " )
@@ -127,7 +127,7 @@ class TestDateInterval: XCTestCase {
127
127
XCTAssertTrue ( dateInterval. contains ( date3) )
128
128
XCTAssertFalse ( dateInterval. contains ( date4) )
129
129
}
130
-
130
+
131
131
func test_hashing( ) {
132
132
guard #available( iOS 10 . 10 , OSX 10 . 12 , tvOS 10 . 0 , watchOS 3 . 0 , * ) else { return }
133
133
0 commit comments