From a8dc7041978a5682fc0504a8728237b6d50706df Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 5 Feb 2020 10:29:43 +0300 Subject: [PATCH] emit: add tests for Int --- pkg/vm/emit/emit_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/vm/emit/emit_test.go b/pkg/vm/emit/emit_test.go index bbb83fc72..ed6c94cd5 100644 --- a/pkg/vm/emit/emit_test.go +++ b/pkg/vm/emit/emit_test.go @@ -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)