test: add an almost arbitrary test for p2
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user