neoneo-go/pkg/util/array_test.go

30 lines
650 B
Go
Raw Normal View History

package util
import (
"testing"
2019-11-24 14:55:50 +00:00
"github.com/stretchr/testify/require"
)
func TestArrayEvenReverse(t *testing.T) {
arr := []byte{0x01, 0x02, 0x03, 0x04}
have := ArrayReverse(arr)
want := []byte{0x04, 0x03, 0x02, 0x01}
2019-11-24 14:55:50 +00:00
require.Equal(t, want, have)
}
func TestArrayOddReverse(t *testing.T) {
arr := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
have := ArrayReverse(arr)
want := []byte{0x05, 0x04, 0x03, 0x02, 0x01}
2019-11-24 14:55:50 +00:00
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}
2019-11-24 14:55:50 +00:00
require.Equal(t, want, have)
}