mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-12 21:10:36 +00:00
1fb66d6b73
GolangCI complained: testArray is unused (from deadcode) But this function was actually wrong being a copy-paste of testMakeStackMap(), it also didn't conform to testMake... naming scheme, so this fixes it. To make thing more uniform NewArray() was also changed to return error, map_test.go code adjusted to this changes and finally array_test.go was added as a stub for future Array testing.
56 lines
1 KiB
Go
56 lines
1 KiB
Go
package stack
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/binary"
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// helper functions
|
|
func testPeakInteger(t *testing.T, tStack *RandomAccess, n uint16) *Int {
|
|
stackElement, err := tStack.Peek(n)
|
|
assert.Nil(t, err)
|
|
item, err := stackElement.Integer()
|
|
if err != nil {
|
|
t.Fail()
|
|
}
|
|
return item
|
|
}
|
|
|
|
func testPopInteger(t *testing.T, tStack *RandomAccess) *Int {
|
|
stackElement, err := tStack.Pop()
|
|
assert.Nil(t, err)
|
|
item, err := stackElement.Integer()
|
|
if err != nil {
|
|
t.Fail()
|
|
}
|
|
return item
|
|
}
|
|
|
|
func testMakeStackInt(t *testing.T, num int64) *Int {
|
|
a, err := NewInt(big.NewInt(num))
|
|
assert.Nil(t, err)
|
|
return a
|
|
}
|
|
|
|
func testReadInt64(data []byte) int64 {
|
|
var ret int64
|
|
buf := bytes.NewBuffer(data)
|
|
binary.Read(buf, binary.LittleEndian, &ret)
|
|
return ret
|
|
}
|
|
|
|
func testMakeStackMap(t *testing.T, m map[Item]Item) *Map {
|
|
a, err := NewMap(m)
|
|
assert.Nil(t, err)
|
|
return a
|
|
}
|
|
|
|
func testMakeArray(t *testing.T, v []Item) *Array {
|
|
a, err := NewArray(v)
|
|
assert.Nil(t, err)
|
|
return a
|
|
}
|