day 1a
This commit is contained in:
parent
c3c1fe8b3a
commit
255c191dfc
3 changed files with 74 additions and 0 deletions
31
day01/day01_test.go
Normal file
31
day01/day01_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestScanFile(t *testing.T) {
|
||||
cases := []struct {
|
||||
inFile string;
|
||||
want int;
|
||||
}{
|
||||
{"input1.txt", 142},
|
||||
}
|
||||
|
||||
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) == %q, want %q", c.inFile, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue