array: add a test for even num of elements

And drop duplicating code from _pkg.dev.
This commit is contained in:
Roman Khimov 2019-08-23 15:44:49 +03:00
parent 0cde8d962d
commit 37be2e215c
3 changed files with 10 additions and 49 deletions

View file

@ -5,7 +5,16 @@ import (
"testing"
)
func TestArrayReverse(t *testing.T) {
func TestArrayEvenReverse(t *testing.T) {
arr := []byte{0x01, 0x02, 0x03, 0x04}
have := ArrayReverse(arr)
want := []byte{0x04, 0x03, 0x02, 0x01}
if !bytes.Equal(have, want) {
t.Fatalf("expected %v got %v", want, have)
}
}
func TestArrayOddReverse(t *testing.T) {
arr := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
have := ArrayReverse(arr)
want := []byte{0x05, 0x04, 0x03, 0x02, 0x01}