-
Notifications
You must be signed in to change notification settings - Fork 215
/
Hard_057_Insert_Interval_Test.swift
176 lines (174 loc) · 4.38 KB
/
Hard_057_Insert_Interval_Test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//
// Hard_057_Insert_Interval_Test.swift
// Solutions
//
// Created by Di Wu on 6/13/15.
// Copyright © 2015 diwu. All rights reserved.
//
import XCTest
class Hard_057_Insert_Interval_Test: XCTestCase, SolutionsTestCase {
func test_001() {
let input0: [[Int]] = [
[1,3],
[6,9]
]
let input1: [Int] = [
2,5
]
let expected: [[Int]] = [
[1,5],
[6,9]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_002() {
let input0: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[12,16]
]
let input1: [Int] = [
4,9
]
let expected: [[Int]] = [
[1,2],
[3,10],
[12,16]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_003() {
let input0: [[Int]] = [
]
let input1: [Int] = [
]
let expected: [[Int]] = [
[]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_004() {
let input0: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[12,16]
]
let input1: [Int] = [
1,16
]
let expected: [[Int]] = [
[1,16]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_005() {
let input0: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[12,16]
]
let input1: [Int] = [
2,15
]
let expected: [[Int]] = [
[1,16]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_006() {
let input0: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[12,16]
]
let input1: [Int] = [
2,17
]
let expected: [[Int]] = [
[1,17]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_007() {
let input0: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[99,100]
]
let input1: [Int] = [
200, 202
]
let expected: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[99,100],
[200,202]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_008() {
let input0: [[Int]] = [
[3,5],
[6,7],
[8,10],
[99,100]
]
let input1: [Int] = [
1,2
]
let expected: [[Int]] = [
[1,2],
[3,5],
[6,7],
[8,10],
[99,100],
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
func test_009() {
let input0: [[Int]] = [
[3,5],
[6,7],
[8,10],
[99,100]
]
let input1: [Int] = [
80,81
]
let expected: [[Int]] = [
[3,5],
[6,7],
[8,10],
[80,81],
[99,100]
]
asyncHelper(input0: input0, input1: input1, expected: expected)
}
private func asyncHelper(input0: [[Int]], input1: [Int], expected: [[Int]]) {
weak var expectation: XCTestExpectation? = self.expectation(description:timeOutName())
serialQueue().async(execute: { () -> Void in
let result = Hard_057_Insert_Interval.insert(intervals: input0, newInterval: input1)
assertHelper(compareTwoDimensionIntArray(arr0: result, arr1: expected), problemName:self.problemName(), input: [input0, input1], resultValue: result, expectedValue: expected)
if let unwrapped = expectation {
unwrapped.fulfill()
}
})
waitForExpectations(timeout:timeOut()) { (error: Error?) -> Void in
if error != nil {
assertHelper(false, problemName:self.problemName(), input: [input0, input1], resultValue:self.timeOutName(), expectedValue: expected)
}
}
}
}