test: add an almost arbitrary test for p2

This commit is contained in:
2025-12-01 23:20:37 +01:00
parent 9caee546f0
commit 6b95f5ced0

View File

@@ -23,3 +23,28 @@ func TestPartOne(t *testing.T) {
t.Errorf("PartOne() = %d, want %d", got, expected)
}
}
func TestPartTwo(t *testing.T) {
instructions := map[string]string{
"x": "10",
"y": "20",
"z": "x AND y",
"b": "z",
"w": "b LSHIFT 1",
"v": "NOT b",
"u": "w OR v",
"a": "u",
}
partOneResult := PartOne(instructions)
bValue := uint16(partOneResult)
w := bValue << 1
v := ^bValue
u := w | v
expected := int(u)
got := PartTwo(instructions)
if got != expected {
t.Errorf("PartTwo() = %d, want %d (PartOne result: %d)", got, expected, partOneResult)
}
}