2018 day 13 - oop-ish solution to carts moving on tracks and colliding

This commit is contained in:
alexchao26
2020-12-01 19:12:10 -05:00
parent 5b1c1472f5
commit 88348ab4e3
4 changed files with 714 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
package main
import (
"testing"
"github.com/alexchao26/advent-of-code-go/util"
)
var tests1 = []struct {
name string
want string
input string
// add extra args if needed
}{
{"example", "7,3", `/->-\
| | /----\
| /-+--+-\ |
| | | | v |
\-+-/ \-+--/
\------/
`},
{"actual", "5,102", 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
// add extra args if needed
}{
{"example", "6,4", `/>-<\
| |
| /<+-\
| | | v
\>+</ |
| ^
\<->/
`},
{"actual", "46,45", 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)
}
})
}
}