test: add unit test for part two
This commit is contained in:
@@ -2,23 +2,45 @@ package dayeleven
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var testInput = []string{
|
|
||||||
"aaa: you hhh",
|
|
||||||
"you: bbb ccc",
|
|
||||||
"bbb: ddd eee",
|
|
||||||
"ccc: ddd eee fff",
|
|
||||||
"ddd: ggg",
|
|
||||||
"eee: out",
|
|
||||||
"fff: out",
|
|
||||||
"ggg: out",
|
|
||||||
"hhh: ccc fff iii",
|
|
||||||
"iii: out",
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPartOne(t *testing.T) {
|
func TestPartOne(t *testing.T) {
|
||||||
|
testInput := []string{
|
||||||
|
"aaa: you hhh",
|
||||||
|
"you: bbb ccc",
|
||||||
|
"bbb: ddd eee",
|
||||||
|
"ccc: ddd eee fff",
|
||||||
|
"ddd: ggg",
|
||||||
|
"eee: out",
|
||||||
|
"fff: out",
|
||||||
|
"ggg: out",
|
||||||
|
"hhh: ccc fff iii",
|
||||||
|
"iii: out",
|
||||||
|
}
|
||||||
expected := 5
|
expected := 5
|
||||||
got := PartOne(testInput)
|
got := PartOne(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPartTwo(t *testing.T) {
|
||||||
|
testInput := []string{
|
||||||
|
"svr: aaa bbb",
|
||||||
|
"aaa: fft",
|
||||||
|
"fft: ccc",
|
||||||
|
"bbb: tty",
|
||||||
|
"tty: ccc",
|
||||||
|
"ccc: ddd eee",
|
||||||
|
"ddd: hub",
|
||||||
|
"hub: fff",
|
||||||
|
"eee: dac",
|
||||||
|
"dac: fff",
|
||||||
|
"fff: ggg hhh",
|
||||||
|
"ggg: out",
|
||||||
|
"hhh: out",
|
||||||
|
}
|
||||||
|
expected := 2
|
||||||
|
got := PartTwo(testInput)
|
||||||
|
if got != expected {
|
||||||
|
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user