a058598ecc
* small fixes * gofmt * bytearray parsing * tests * removed unnecessary files * added more types for bytearray * iter * made TryParseArray parameter variadic * fixes after review * fix after review * misprints * updated array reverse * imports/fmt * naming
25 lines
544 B
Go
25 lines
544 B
Go
package util
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestArrayReverse(t *testing.T) {
|
|
arr := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
|
|
have := ArrayReverse(arr)
|
|
want := []byte{0x05, 0x04, 0x03, 0x02, 0x01}
|
|
if bytes.Compare(have, want) != 0 {
|
|
t.Fatalf("expected %v got %v", want, have)
|
|
}
|
|
}
|
|
|
|
// This tests a bug that occured with arrays of size 1
|
|
func TestArrayReverseLen2(t *testing.T) {
|
|
arr := []byte{0x01}
|
|
have := ArrayReverse(arr)
|
|
want := []byte{0x01}
|
|
if bytes.Compare(have, want) != 0 {
|
|
t.Fatalf("expected %v got %v", want, have)
|
|
}
|
|
}
|