mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-18 19:13:27 +02:00
71 lines
1.0 KiB
Go
71 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var example = `1abc2
|
|
pqr3stu8vwx
|
|
a1b2c3d4e5f
|
|
treb7uchet`
|
|
|
|
func Test_part1(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
{
|
|
name: "example",
|
|
input: example,
|
|
want: 142,
|
|
},
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: 55488,
|
|
},
|
|
}
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var example2 = `two1nine
|
|
eightwothree
|
|
abcone2threexyz
|
|
xtwone3four
|
|
4nineeightseven2
|
|
zoneight234
|
|
7pqrstsixteen`
|
|
|
|
func Test_part2(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want int
|
|
}{
|
|
{
|
|
name: "example",
|
|
input: example2,
|
|
want: 281,
|
|
},
|
|
{
|
|
name: "actual",
|
|
input: input,
|
|
want: 55614,
|
|
},
|
|
}
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
}
|