This commit is contained in:
Katherina Walshe-Grey 2024-11-04 19:18:21 +00:00
parent 7e3b20a8c8
commit 8b6ea615f7
3 changed files with 118 additions and 0 deletions

31
day02/day02_test.go Normal file
View file

@ -0,0 +1,31 @@
package main
import (
"os"
"testing"
)
func TestScanFile(t *testing.T) {
cases := []struct {
inFile string;
want int;
}{
{"input1.txt", 8},
}
for _, c := range cases {
f, err := os.Open(c.inFile)
if err != nil {
t.Fatal(err)
}
got, err := ScanFile(f)
if err != nil {
t.Fatal(err)
}
if got != c.want {
t.Errorf("ScanFile(%q) == %d, want %d", c.inFile, got, c.want)
}
}
}