mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-12 21:10:36 +00:00
ddd1d92ff1
The idea here is to preserve the history of `dev` branch development and its code when merging with the `master`. Later this code could be moved into the masters code where appropriate.
33 lines
780 B
Go
33 lines
780 B
Go
package slice
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestSliceReverse(t *testing.T) {
|
|
arr := []byte{0x01, 0x02, 0x03, 0x04}
|
|
have := Reverse(arr)
|
|
want := []byte{0x04, 0x03, 0x02, 0x01}
|
|
if bytes.Compare(have, want) != 0 {
|
|
t.Fatalf("expected %v got %v", want, have)
|
|
}
|
|
}
|
|
func TestSliceReverseOddNumberOfElements(t *testing.T) {
|
|
arr := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
|
|
have := Reverse(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 TestSliceReverseLen2(t *testing.T) {
|
|
arr := []byte{0x01}
|
|
have := Reverse(arr)
|
|
want := []byte{0x01}
|
|
if bytes.Compare(have, want) != 0 {
|
|
t.Fatalf("expected %v got %v", want, have)
|
|
}
|
|
}
|