You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vm_test.go 639B

1234567891011121314151617181920212223242526
  1. package intcode
  2. import (
  3. "reflect"
  4. "testing"
  5. )
  6. func TestDayTwoSamples(t *testing.T) {
  7. tables := []struct {
  8. given []int
  9. expected []int
  10. }{
  11. {[]int{1, 0, 0, 0, 99}, []int{2, 0, 0, 0, 99}},
  12. {[]int{2, 3, 0, 3, 99}, []int{2, 3, 0, 6, 99}},
  13. {[]int{2, 4, 4, 5, 99, 0}, []int{2, 4, 4, 5, 99, 9801}},
  14. {[]int{1, 1, 1, 4, 99, 5, 6, 0, 99}, []int{30, 1, 1, 4, 2, 5, 6, 0, 99}},
  15. }
  16. for _, table := range tables {
  17. vm := NewVirtualMachine(table.given)
  18. vm.Run()
  19. if !reflect.DeepEqual(table.expected, vm.Memory) {
  20. t.Errorf("Evaluation of %v was incorrect, got: %v, want: %v.", table.given, vm.Memory, table.expected)
  21. }
  22. }
  23. }