mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
util: refactor tests for ArrayReverse
This commit is contained in:
parent
70c22ebc7b
commit
d07d6f3371
1 changed files with 25 additions and 18 deletions
|
@ -6,24 +6,31 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestArrayEvenReverse(t *testing.T) {
|
var testCases = []struct {
|
||||||
arr := []byte{0x01, 0x02, 0x03, 0x04}
|
arr []byte
|
||||||
have := ArrayReverse(arr)
|
rev []byte
|
||||||
want := []byte{0x04, 0x03, 0x02, 0x01}
|
}{
|
||||||
require.Equal(t, want, have)
|
{
|
||||||
|
arr: []byte{},
|
||||||
|
rev: []byte{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arr: []byte{0x01},
|
||||||
|
rev: []byte{0x01},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arr: []byte{0x01, 0x02, 0x03, 0x04},
|
||||||
|
rev: []byte{0x04, 0x03, 0x02, 0x01},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arr: []byte{0x01, 0x02, 0x03, 0x04, 0x05},
|
||||||
|
rev: []byte{0x05, 0x04, 0x03, 0x02, 0x01},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestArrayOddReverse(t *testing.T) {
|
func TestArrayReverse(t *testing.T) {
|
||||||
arr := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
|
for _, tc := range testCases {
|
||||||
have := ArrayReverse(arr)
|
have := ArrayReverse(tc.arr)
|
||||||
want := []byte{0x05, 0x04, 0x03, 0x02, 0x01}
|
require.Equal(t, tc.rev, have)
|
||||||
require.Equal(t, want, have)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// This tests a bug that occurred with arrays of size 1
|
|
||||||
func TestArrayReverseLen2(t *testing.T) {
|
|
||||||
arr := []byte{0x01}
|
|
||||||
have := ArrayReverse(arr)
|
|
||||||
want := []byte{0x01}
|
|
||||||
require.Equal(t, want, have)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue