-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm_test.go
41 lines (37 loc) · 946 Bytes
/
vm_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package go8086
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestVMFlag(t *testing.T) {
vm := NewVM()
assert.Equal(t, 0, vm.GetFlag(CF))
assert.Equal(t, 0, vm.GetFlag(OF))
vm.flag = 0x0001
assert.Equal(t, 1, vm.GetFlag(CF))
assert.Equal(t, 0, vm.GetFlag(OF))
vm.flag = 0x0400
assert.Equal(t, 0, vm.GetFlag(CF))
assert.Equal(t, 1, vm.GetFlag(OF))
}
func TestVMSetFlag(t *testing.T) {
vm := NewVM()
assert.Equal(t, 0, vm.GetFlag(CF))
vm.SetFlag(CF, true)
assert.Equal(t, 1, vm.GetFlag(CF))
assert.Equal(t, 0x0001, vm.flag)
vm.SetFlag(CF, true)
assert.Equal(t, 1, vm.GetFlag(CF))
assert.Equal(t, 0x0001, vm.flag)
}
func TestVMClearFlag(t *testing.T) {
vm := NewVM()
vm.flag = 0x0001
assert.Equal(t, 1, vm.GetFlag(CF))
vm.SetFlag(CF, false)
assert.Equal(t, 0, vm.GetFlag(CF))
assert.Equal(t, 0x0000, vm.flag)
vm.SetFlag(CF, false)
assert.Equal(t, 0, vm.GetFlag(CF))
assert.Equal(t, 0x0000, vm.flag)
}