test: add unit test for part two
This commit is contained in:
@@ -21,3 +21,31 @@ func TestPartOne(t *testing.T) {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
secondTestInput := []string{
|
||||
"shiny gold bags contain 2 dark red bags.",
|
||||
"dark red bags contain 2 dark orange bags.",
|
||||
"dark orange bags contain 2 dark yellow bags.",
|
||||
"dark yellow bags contain 2 dark green bags.",
|
||||
"dark green bags contain 2 dark blue bags.",
|
||||
"dark blue bags contain 2 dark violet bags.",
|
||||
"dark violet bags contain no other bags.",
|
||||
}
|
||||
|
||||
t.Run("First Example", func(t *testing.T) {
|
||||
expected := 32
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Second Example", func(t *testing.T) {
|
||||
expected := 126
|
||||
got := PartTwo(secondTestInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user