emit: add tests for Int

This commit is contained in:
Evgenii Stratonikov 2020-02-05 10:29:43 +03:00
parent 6fd3f0fa48
commit a8dc704197

View file

@ -11,6 +11,22 @@ import (
)
func TestEmitInt(t *testing.T) {
t.Run("minis one", func(t *testing.T) {
buf := io.NewBufBinWriter()
Int(buf.BinWriter, -1)
result := buf.Bytes()
assert.Len(t, result, 1)
assert.EqualValues(t, opcode.PUSHM1, result[0])
})
t.Run("zero", func(t *testing.T) {
buf := io.NewBufBinWriter()
Int(buf.BinWriter, 0)
result := buf.Bytes()
assert.Len(t, result, 1)
assert.EqualValues(t, opcode.PUSH0, result[0])
})
t.Run("1-byte int", func(t *testing.T) {
buf := io.NewBufBinWriter()
Int(buf.BinWriter, 10)