mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 14:50:46 +00:00
34 lines
627 B
Go
34 lines
627 B
Go
|
package two
|
||
|
|
||
|
import (
|
||
|
"slices"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestComputerRunProgram1(t *testing.T) {
|
||
|
tt := map[string]struct {
|
||
|
registers map[string]int64
|
||
|
program []int64
|
||
|
}{
|
||
|
"register C contains 9 with program 2,6, should set register B to 1": {
|
||
|
registers: map[string]int64{
|
||
|
"A": 117440,
|
||
|
"B": 0,
|
||
|
"C": 0,
|
||
|
},
|
||
|
program: []int64{0, 3, 5, 4, 3, 0},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
c := newComputer(nil)
|
||
|
for name, tc := range tt {
|
||
|
t.Run(name, func(t *testing.T) {
|
||
|
c.registers = tc.registers
|
||
|
got := c.run(tc.program)
|
||
|
if !slices.Equal(got, tc.program) {
|
||
|
t.Errorf("output: %q, expected %q", got, tc.program)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|