-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay11_test.go
95 lines (90 loc) · 2.96 KB
/
Day11_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
package main
import (
"reflect"
"strings"
"testing"
)
func TestComputeDay11a(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want int
}{
{ "Day 11 Part 1 - Example", args {"L.LL.LL.LL\nLLLLLLL.LL\nL.L.L..L..\nLLLL.LL.LL\nL.LL.LL.LL\nL.LLLLL.LL\n..L.L.....\nLLLLLLLLLL\nL.LLLLLL.L\nL.LLLLL.LL"}, 37 },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ComputeDay11a(tt.args.input); got != tt.want {
t.Errorf("ComputeDay11a() = %v, want %v", got, tt.want)
}
})
}
}
func TestComputeDay11b(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want int
}{
{ "Day 11 Part 2 - Example", args {"L.LL.LL.LL\nLLLLLLL.LL\nL.L.L..L..\nLLLL.LL.LL\nL.LL.LL.LL\nL.LLLLL.LL\n..L.L.....\nLLLLLLLLLL\nL.LLLLLL.L\nL.LLLLL.LL"}, 26 },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ComputeDay11b(tt.args.input); got != tt.want {
t.Errorf("ComputeDay11b() = %v, want %v", got, tt.want)
}
})
}
}
func TestComputeNumberOccupiedVisibleSeats(t *testing.T) {
type args struct {
grid []string
i int
j int
}
tests := []struct {
name string
args args
want int
}{
{ "Test visible occupied seats 1", args {strings.Split(".......#.\n...#.....\n.#.......\n.........\n..#L....#\n....#....\n.........\n#........\n...#.....", "\n"), 4, 3 }, 8},
{ "Test visible occupied seats 2", args {strings.Split(".##.##.\n#.#.#.#\n##...##\n...L...\n##...##\n#.#.#.#\n.##.##.", "\n"), 3, 3 }, 0},
{ "Test visible occupied seats 3", args {strings.Split(".............\n.L.L.#.#.#.#.\n.............", "\n"), 1, 1 }, 0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NumberOccupiedVisibleSeats(tt.args.grid, tt.args.i, tt.args.j); got != tt.want {
t.Errorf("NumberOccupiedVisibleSeats() = %v, want %v", got, tt.want)
}
})
}
}
func TestComputeNextSeating(t *testing.T) {
type args struct {
grid []string
part2 bool
}
tests := []struct {
name string
args args
want []string
}{
/*{"Test next seating 2", args {strings.Split("#.L#.L#.L#\n#LLLLLL.LL\nL.L.L..#..\n##L#.#L.L#\nL.L#.LL.L#\n#.LLLL#.LL\n..#.L.....\nLLL###LLL#\n#.LLLLL#.L\n#.L#LL#.L#","\n"), true},
strings.Split("#.L#.L#.L#\n#LLLLLL.LL\nL.L.L..#..\n##L#.#L.L#\nL.L#.LL.L#\n#.LLLL#.LL\n..#.L.....\nLLL###LLL#\n#.LLLLL#.L\n#.L#LL#.L#", "\n")},*/
{"Test next seating 2", args {strings.Split("#.L#.##.L#\n#L#####.LL\nL.#.#..#..\n##L#.##.##\n#.##.#L.##\n#.#####.#L\n..#.#.....\nLLL####LL#\n#.L#####.L\n#.L####.L#","\n"), true},
strings.Split("#.L#.L#.L#\n#LLLLLL.LL\nL.L.L..#..\n##LL.LL.L#\nL.LL.LL.L#\n#.LLLLL.LL\n..L.L.....\nLLLLLLLLL#\n#.LLLLL#.L\n#.L#LL#.L#", "\n")},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := computeNextSeating(tt.args.grid, tt.args.part2); !reflect.DeepEqual(got, tt.want) {
t.Errorf("computeNextSeating() = %v, want %v", got, tt.want)
}
})
}
}