test: add unit tests for both parts
This commit is contained in:
45
internal/2015/DayFour/code_test.go
Normal file
45
internal/2015/DayFour/code_test.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package dayfour
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPartOne(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input []byte
|
||||||
|
expected int
|
||||||
|
}{
|
||||||
|
{"abcdef", []byte("abcdef"), 609043},
|
||||||
|
{"pqrstuv", []byte("pqrstuv"), 1048970},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := PartOne(tt.input)
|
||||||
|
if got != tt.expected {
|
||||||
|
t.Errorf("PartOne() = %d, want %d", got, tt.expected)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPartTwo(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input []byte
|
||||||
|
expected int
|
||||||
|
}{
|
||||||
|
{"abcdef", []byte("abcdef"), 6742839},
|
||||||
|
{"pqrstuv", []byte("pqrstuv"), 5714438},
|
||||||
|
}
|
||||||
|
|
||||||
|
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