From 31f4c7486bedd009c1fb7b39afd6a9d36ba7d1c3 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 10 Sep 2019 17:28:53 +0300 Subject: [PATCH] vm: add tests for CAT --- pkg/vm/vm_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index 18c6f0316..9506c7404 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -729,6 +729,28 @@ func TestCATGood(t *testing.T) { assert.Equal(t, []byte("abcdef"), vm.estack.Peek(0).Bytes()) } +func TestCATInt0ByteArray(t *testing.T) { + prog := makeProgram(CAT) + vm := load(prog) + vm.estack.PushVal(0) + vm.estack.PushVal([]byte{}) + vm.Run() + assert.Equal(t, false, vm.state.HasFlag(faultState)) + assert.Equal(t, 1, vm.estack.Len()) + assert.Equal(t, &ByteArrayItem{[]byte{}}, vm.estack.Pop().value) +} + +func TestCATByteArrayInt1(t *testing.T) { + prog := makeProgram(CAT) + vm := load(prog) + vm.estack.PushVal([]byte{}) + vm.estack.PushVal(1) + vm.Run() + assert.Equal(t, false, vm.state.HasFlag(faultState)) + assert.Equal(t, 1, vm.estack.Len()) + assert.Equal(t, &ByteArrayItem{[]byte{1}}, vm.estack.Pop().value) +} + func TestSUBSTRBadNoArgs(t *testing.T) { prog := makeProgram(SUBSTR) vm := load(prog)