util: make tests use require

This commit is contained in:
Evgenii Stratonikov 2019-11-24 17:55:50 +03:00
parent ea9bc22510
commit 116d4c656e
3 changed files with 32 additions and 76 deletions

View file

@ -1,26 +1,23 @@
package util
import (
"bytes"
"testing"
"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}
if !bytes.Equal(have, want) {
t.Fatalf("expected %v got %v", want, have)
}
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}
if !bytes.Equal(have, want) {
t.Fatalf("expected %v got %v", want, have)
}
require.Equal(t, want, have)
}
// This tests a bug that occurred with arrays of size 1
@ -28,7 +25,5 @@ func TestArrayReverseLen2(t *testing.T) {
arr := []byte{0x01}
have := ArrayReverse(arr)
want := []byte{0x01}
if !bytes.Equal(have, want) {
t.Fatalf("expected %v got %v", want, have)
}
require.Equal(t, want, have)
}