advent-of-code/2025/day05/day05_test.go
C4 Patino ed7885cb22
Some checks failed
gofmt / format (push) Has been cancelled
feat: completed day 5 for advent of code 2025
2025-12-04 23:46:24 -06:00

34 lines
719 B
Go
Executable file

package day05
import (
"os"
"testing"
)
type TestCase struct {
FileName string
Part1 any
Part2 any
}
func TestDay05(t *testing.T) {
tests := []TestCase{
{"test.txt", 3, 14},
{"input.txt", 798, 366181852921027},
}
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)
}
}
}