From c708aca1f62b7d6b32823abce5ae0e28cd262a90 Mon Sep 17 00:00:00 2001 From: Kharec Date: Mon, 24 Nov 2025 14:01:52 +0100 Subject: [PATCH] test: add unit test --- 2020/day03/main_test.go | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 2020/day03/main_test.go diff --git a/2020/day03/main_test.go b/2020/day03/main_test.go new file mode 100644 index 0000000..196962d --- /dev/null +++ b/2020/day03/main_test.go @@ -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) + } +}