Added more tests

This commit is contained in:
Eduard Urbach 2024-06-27 21:39:04 +02:00
parent b6947dab18
commit d77660cdb8
Signed by: eduard
GPG key ID: 49226B848C78F6C8
5 changed files with 61 additions and 8 deletions

View file

@ -0,0 +1,31 @@
package x64_test
import (
"testing"
"git.akyoto.dev/cli/q/src/build/arch/x64"
"git.akyoto.dev/go/assert"
)
func TestJump8(t *testing.T) {
usagePatterns := []struct {
Offset int8
Code []byte
}{
{0, []byte{0xEB, 0x00}},
{1, []byte{0xEB, 0x01}},
{2, []byte{0xEB, 0x02}},
{3, []byte{0xEB, 0x03}},
{127, []byte{0xEB, 0x7F}},
{-1, []byte{0xEB, 0xFF}},
{-2, []byte{0xEB, 0xFE}},
{-3, []byte{0xEB, 0xFD}},
{-128, []byte{0xEB, 0x80}},
}
for _, pattern := range usagePatterns {
t.Logf("jmp %x", pattern.Offset)
code := x64.Jump8(nil, pattern.Offset)
assert.DeepEqual(t, code, pattern.Code)
}
}