array: add a test for even num of elements
And drop duplicating code from _pkg.dev.
This commit is contained in:
parent
0cde8d962d
commit
37be2e215c
3 changed files with 10 additions and 49 deletions
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue