test: add unit test for part two
This commit is contained in:
@@ -2,8 +2,7 @@ package dayfour
|
|||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
func TestPartOne(t *testing.T) {
|
var testInput = []string{
|
||||||
input := []string{
|
|
||||||
"[1518-11-01 00:00] Guard #10 begins shift",
|
"[1518-11-01 00:00] Guard #10 begins shift",
|
||||||
"[1518-11-01 00:05] falls asleep",
|
"[1518-11-01 00:05] falls asleep",
|
||||||
"[1518-11-01 00:25] wakes up",
|
"[1518-11-01 00:25] wakes up",
|
||||||
@@ -21,10 +20,20 @@ func TestPartOne(t *testing.T) {
|
|||||||
"[1518-11-05 00:03] Guard #99 begins shift",
|
"[1518-11-05 00:03] Guard #99 begins shift",
|
||||||
"[1518-11-05 00:45] falls asleep",
|
"[1518-11-05 00:45] falls asleep",
|
||||||
"[1518-11-05 00:55] wakes up",
|
"[1518-11-05 00:55] wakes up",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPartOne(t *testing.T) {
|
||||||
expected := 240
|
expected := 240
|
||||||
got := PartOne(input)
|
got := PartOne(testInput)
|
||||||
if got != expected {
|
if got != expected {
|
||||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPartTwo(t *testing.T) {
|
||||||
|
expected := 4455
|
||||||
|
got := PartTwo(testInput)
|
||||||
|
if got != expected {
|
||||||
|
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user