mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-19 03:23:27 +02:00
50 lines
901 B
Go
50 lines
901 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alexchao26/advent-of-code-go/util"
|
|
)
|
|
|
|
var tests1 = []struct {
|
|
name string
|
|
want string
|
|
input string
|
|
}{
|
|
{"example 1", "33,45", "18"},
|
|
{"example 2", "21,61", "42"},
|
|
{"actual", "34,72", util.ReadFile("input.txt")},
|
|
}
|
|
|
|
func TestPart1(t *testing.T) {
|
|
for _, test := range tests1 {
|
|
t.Run(test.name, func(*testing.T) {
|
|
got := part1(test.input)
|
|
if got != test.want {
|
|
t.Errorf("got %v, want %v", got, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var tests2 = []struct {
|
|
name string
|
|
want string
|
|
input string
|
|
}{
|
|
{"example 1", "90,269,16", "18"},
|
|
{"example 2", "232,251,12", "42"},
|
|
{"actual", "233,187,13", util.ReadFile("input.txt")},
|
|
}
|
|
|
|
func TestPart2(t *testing.T) {
|
|
for _, test := range tests2 {
|
|
t.Run(test.name, func(*testing.T) {
|
|
got := part2(test.input)
|
|
if got != test.want {
|
|
t.Errorf("got %v, want %v", got, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|