test: add unit test

This commit is contained in:
2025-11-24 14:01:52 +01:00
parent 2528bb064a
commit c708aca1f6

45
2020/day03/main_test.go Normal file
View File

@@ -0,0 +1,45 @@
package main
import "testing"
func TestPartOne(t *testing.T) {
input := []string{
"..##.......",
"#...#...#..",
".#....#..#.",
"..#.#...#.#",
".#...##..#.",
"..#.##.....",
".#.#.#....#",
".#........#",
"#.##...#...",
"#...##....#",
".#..#...#.#",
}
expected := 7
got := PartOne(input)
if got != expected {
t.Errorf("PartOne() = %d, want %d", got, expected)
}
}
func TestPartTwo(t *testing.T) {
input := []string{
"..##.......",
"#...#...#..",
".#....#..#.",
"..#.#...#.#",
".#...##..#.",
"..#.##.....",
".#.#.#....#",
".#........#",
"#.##...#...",
"#...##....#",
".#..#...#.#",
}
expected := 336
got := PartTwo(input)
if got != expected {
t.Errorf("PartTwo() = %d, want %d", got, expected)
}
}