test: add unit tests for both parts

This commit is contained in:
2025-11-29 09:57:23 +01:00
parent 8d69f10924
commit a12c8df252

View 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)
}
})
}
}