-
Notifications
You must be signed in to change notification settings - Fork 2
/
distiller_test.go
126 lines (107 loc) · 2.9 KB
/
distiller_test.go
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
package distil
import (
"testing"
)
func testExpandPrereqsParallel(t *testing.T, input []TimeRange, expoutput []TimeRange) {
var output = expandPrereqsParallel(input)
if len(output) != len(expoutput) {
t.Fatalf("Output has %d intervals (expected %d)", len(output), len(expoutput))
}
var i int
for i = 0; i < len(output); i++ {
if expoutput[i].Start != output[i].Start {
t.Logf("Got [%d, %d) at entry %d; expected [%d, %d)", output[i].Start, output[i].End, i, expoutput[i].Start, expoutput[i].End)
t.Fail()
}
}
}
func TestAllSeparate(t *testing.T) {
var input = make([]TimeRange, 5)
input[0].Start = 0
input[0].End = 1
input[1].Start = 3
input[1].End = 7
input[2].Start = 8
input[2].End = 9
input[3].Start = 10
input[3].End = 123
input[4].Start = 123456
input[4].End = 2102031928
var expoutput = make([]TimeRange, len(input))
copy(expoutput, input)
testExpandPrereqsParallel(t, input, expoutput)
}
func TestTouching(t *testing.T) {
var input = make([]TimeRange, 5)
input[0].Start = 0
input[0].End = 1
input[1].Start = 1
input[1].End = 4
input[2].Start = 4
input[2].End = 122
input[3].Start = 122
input[3].End = 123
input[4].Start = 123
input[4].End = 2102031928
var expoutput = make([]TimeRange, 1)
expoutput[0].Start = input[0].Start
expoutput[0].End = input[len(input)-1].End
testExpandPrereqsParallel(t, input, expoutput)
}
func TestTouchingSeparate(t *testing.T) {
var input = make([]TimeRange, 5)
input[0].Start = 0
input[0].End = 1
input[1].Start = 1
input[1].End = 4
input[2].Start = 5
input[2].End = 122
input[3].Start = 122
input[3].End = 123
input[4].Start = 123
input[4].End = 2102031928
var expoutput = make([]TimeRange, 2)
expoutput[0].Start = input[0].Start
expoutput[0].End = input[1].End
expoutput[1].Start = input[2].Start
expoutput[1].End = input[len(input)-1].End
testExpandPrereqsParallel(t, input, expoutput)
}
func TestOverlap(t *testing.T) {
var input = make([]TimeRange, 5)
input[0].Start = 0
input[0].End = 2
input[1].Start = 1
input[1].End = 4
input[2].Start = 6
input[2].End = 122
input[3].Start = 120
input[3].End = 2102031927
input[4].Start = 123
input[4].End = 2102031928
var expoutput = make([]TimeRange, 2)
expoutput[0].Start = input[0].Start
expoutput[0].End = input[1].End
expoutput[1].Start = input[2].Start
expoutput[1].End = input[len(input)-1].End
testExpandPrereqsParallel(t, input, expoutput)
}
func TestTouchOverlapSubsume(t *testing.T) {
var input = make([]TimeRange, 5)
input[0].Start = 0
input[0].End = 2
input[1].Start = 0
input[1].End = 4
input[2].Start = 6
input[2].End = 120
input[3].Start = 120
input[3].End = 2102031927
input[4].Start = 123
input[4].End = 2102031928
var expoutput = make([]TimeRange, 2)
expoutput[0].Start = input[0].Start
expoutput[0].End = input[1].End
expoutput[1].Start = input[2].Start
expoutput[1].End = input[len(input)-1].End
testExpandPrereqsParallel(t, input, expoutput)
}