Files
advent-of-code-go/2017/day12/main_test.go
T
2020-12-15 20:24:52 -05:00

55 lines
990 B
Go

package main
import (
"testing"
"time"
"github.com/alexchao26/advent-of-code-go/util"
)
var example = `0 <-> 2
1 <-> 1
2 <-> 0, 3, 4
3 <-> 2, 4
4 <-> 2, 3, 6
5 <-> 6
6 <-> 4, 5`
func Test_part1(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{"example", example, 6},
{"actual", util.ReadFile("input.txt"), 169},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.input); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
}
})
}
}
func Test_part2(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{"example", example, 2},
{"actual", util.ReadFile("input.txt"), 179},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
startTime := time.Now()
if got := part2(tt.input); got != tt.want {
t.Errorf("part2() = %v, want %v", got, tt.want)
}
t.Logf("Run time for %s: %v", tt.name, time.Since(startTime))
})
}
}