mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-07 20:53:30 +02:00
2018 day 11 - summing subgrids of a 2D grid
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user