mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
76 lines
1.2 KiB
Go
76 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var example = ` ...#
|
|
.#..
|
|
#...
|
|
....
|
|
...#.......#
|
|
........#...
|
|
..#....#....
|
|
..........#.
|
|
...#....
|
|
.....#..
|
|
.#......
|
|
......#.
|
|
|
|
10R5L5R10L4R5L5`
|
|
|
|
func Test_part1(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
{
|
|
name: "example",
|
|
input: example,
|
|
want: 6032,
|
|
},
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: 144244,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := part1(tt.input); got != tt.want {
|
|
t.Errorf("part1() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_part2(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
// NOTE: did not account for the example case because I manually coded
|
|
// for the shape of my exact input... which differed from the
|
|
// input shape
|
|
// {
|
|
// name: "example",
|
|
// input: example,
|
|
// want: 5031,
|
|
// },
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: 138131,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := part2(tt.input); got != tt.want {
|
|
t.Errorf("part2() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|