34 lines
708 B
Go
Executable file
34 lines
708 B
Go
Executable file
package day12
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
type TestCase struct {
|
|
FileName string
|
|
Part1 any
|
|
Part2 any
|
|
}
|
|
|
|
func TestDay12(t *testing.T) {
|
|
tests := []TestCase{
|
|
{"test.txt", 2, nil},
|
|
{"input.txt", 469, nil},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
if _, err := os.Stat(test.FileName); os.IsNotExist(err) {
|
|
t.Fatalf("test file does not exist: %v", test.FileName)
|
|
}
|
|
|
|
part1, part2 := Run(test.FileName)
|
|
if test.Part1 != nil && part1 != test.Part1 {
|
|
t.Fatalf("%s: unexpected part1:\nwant:\t%v\ngot:\t%v", test.FileName, test.Part1, part1)
|
|
}
|
|
|
|
if test.Part2 != nil && part2 != test.Part2 {
|
|
t.Fatalf("%s: unexpected part2:\nwant:\t%v\ngot:\t%v", test.FileName, test.Part2, part2)
|
|
}
|
|
}
|
|
}
|