test: add unit test for part two
This commit is contained in:
@@ -39,3 +39,46 @@ func TestPartOne(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input []int
|
||||
expected int
|
||||
}{
|
||||
{
|
||||
name: "1212 produces 6",
|
||||
input: []int{1, 2, 1, 2},
|
||||
expected: 6,
|
||||
},
|
||||
{
|
||||
name: "1221 produces 0",
|
||||
input: []int{1, 2, 2, 1},
|
||||
expected: 0,
|
||||
},
|
||||
{
|
||||
name: "123425 produces 4",
|
||||
input: []int{1, 2, 3, 4, 2, 5},
|
||||
expected: 4,
|
||||
},
|
||||
{
|
||||
name: "123123 produces 12",
|
||||
input: []int{1, 2, 3, 1, 2, 3},
|
||||
expected: 12,
|
||||
},
|
||||
{
|
||||
name: "12131415 produces 4",
|
||||
input: []int{1, 2, 1, 3, 1, 4, 1, 5},
|
||||
expected: 4,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := PartTwo(tt.input)
|
||||
if got != tt.expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user