-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_test.go
60 lines (54 loc) · 1.23 KB
/
04_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
package main
import "testing"
func TestAOC2022041(t *testing.T) {
var tests = []struct {
input string
fullOverlap bool
partialOverlap bool
}{
{
input: "2-4,6-8",
fullOverlap: false,
partialOverlap: false,
},
{
input: "2-3,4-5",
fullOverlap: false,
partialOverlap: false,
},
{
input: "5-7,7-9",
fullOverlap: false,
partialOverlap: true,
},
{
input: "2-8,3-7",
fullOverlap: true,
partialOverlap: true,
},
{
input: "6-6,4-6",
fullOverlap: true,
partialOverlap: true,
},
{
input: "2-6,4-8",
fullOverlap: false,
partialOverlap: true,
},
}
for _, test := range tests {
left, right, err := AOC202204Parse(test.input)
if err != nil {
t.Errorf("AOC202204Parse(%s) err: %v", test.input, err)
}
got := AOC202204FullOverlap(left, right)
if got != test.fullOverlap {
t.Errorf("AOC202204FullOverlap(%s) missmatch:\nwant: %t\ngot: %t", test.input, test.fullOverlap, got)
}
got = AOC202204PartialOverlap(left, right)
if got != test.partialOverlap {
t.Errorf("AOC202204PartialOverlap(%s) missmatch:\nwant: %t\ngot: %t", test.input, test.partialOverlap, got)
}
}
}