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