-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
86 lines (77 loc) · 1.34 KB
/
main_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
package main
import "testing"
func TestPart1(t *testing.T) {
input := []string{
"30373",
"25512",
"65332",
"33549",
"35390",
}
if got, want := part1(input), 21; got != want {
t.Errorf("got %d, want %d", got, want)
}
}
func TestPart2(t *testing.T) {
input := []string{
"30373",
"25512",
"65332",
"33549",
"35390",
}
if got, want := part2(input), 8; got != want {
t.Errorf("got %d, want %d", got, want)
}
}
func TestVisible(t *testing.T) {
input := []string{
"30373",
"25512",
"65332",
"33549",
"35390",
}
for n, tc := range []struct {
x, y int
visible bool
}{
{0, 0, true},
{4, 0, true},
{0, 4, true},
{4, 4, true},
{1, 1, true},
{2, 1, true},
{3, 1, false},
{1, 2, true},
{2, 2, false},
{3, 2, true},
{1, 3, false},
{2, 3, true},
{3, 3, false},
} {
if got, want := visible(input, tc.x, tc.y), tc.visible; got != want {
t.Errorf("[%d] (%d, %d) got %t, want %t", n, tc.x, tc.y, got, want)
}
}
}
func TestScenicScore(t *testing.T) {
input := []string{
"30373",
"25512",
"65332",
"33549",
"35390",
}
for n, tc := range []struct {
x, y int
score int
}{
{x: 2, y: 1, score: 4},
{x: 2, y: 3, score: 8},
} {
if got, want := scenicScore(input, tc.x, tc.y), tc.score; got != want {
t.Errorf("[%d] (%d, %d) got %d, want %d", n, tc.x, tc.y, got, want)
}
}
}