test: add unit test

This commit is contained in:
2025-11-24 13:20:32 +01:00
parent 42b41dc56d
commit 84cced41a5

29
2020/day02/main_test.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "testing"
func TestPartOne(t *testing.T) {
input := []string{
"1-3 a: abcde",
"1-3 b: cdefg",
"2-9 c: ccccccccc",
}
expected := 2
got := PartOne(input)
if got != expected {
t.Errorf("PartOne(%v) = %d, want %d", input, got, expected)
}
}
func TestPartTwo(t *testing.T) {
input := []string{
"1-3 a: abcde",
"1-3 b: cdefg",
"2-9 c: ccccccccc",
}
expected := 1
got := PartTwo(input)
if got != expected {
t.Errorf("PartOne(%v) = %d, want %d", input, got, expected)
}
}