test: add test for part two

This commit is contained in:
2025-12-12 18:35:05 +01:00
parent db7c31cb39
commit 1adc10ea88

View File

@@ -32,3 +32,27 @@ func TestPartOne(t *testing.T) {
t.Errorf("PartOne() printed %q, want %q", got, expected) t.Errorf("PartOne() printed %q, want %q", got, expected)
} }
} }
func TestPartTwo(t *testing.T) {
expected := "05ace8e3"
oldStdout := os.Stdout
r, w, err := os.Pipe()
if err != nil {
t.Fatalf("Failed to create pipe: %v", err)
}
os.Stdout = w
PartTwo(testInput)
_ = w.Close()
os.Stdout = oldStdout
var buffer bytes.Buffer
_, _ = buffer.ReadFrom(r)
got := strings.TrimSpace(buffer.String())
if got != expected {
t.Errorf("PartTwo() printed %q, want %q", got, expected)
}
}