test: add unit test
This commit is contained in:
45
2020/day03/main_test.go
Normal file
45
2020/day03/main_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user