mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
72 lines
1.1 KiB
Go
72 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var example = `jqt: rhn xhk nvd
|
|
rsh: frs pzl lsr
|
|
xhk: hfx
|
|
cmg: qnr nvd lhk bvb
|
|
rhn: xhk bvb hfx
|
|
bvb: xhk hfx
|
|
pzl: lsr hfx nvd
|
|
qnr: nvd
|
|
ntq: jqt hfx bvb xhk
|
|
nvd: lhk
|
|
lsr: lhk
|
|
rzs: qnr cmg lsr rsh
|
|
frs: qnr lhk lsr`
|
|
|
|
func Test_part1(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
{
|
|
name: "example",
|
|
input: example,
|
|
want: 54,
|
|
},
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: 567606,
|
|
},
|
|
}
|
|
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 string
|
|
}{
|
|
{
|
|
name: "example",
|
|
input: example,
|
|
want: "happiness",
|
|
},
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: "happiness",
|
|
},
|
|
}
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
}
|