github.com/wrgl/wrgl@v0.14.0/pkg/testutils/bytes.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright © 2022 Wrangle Ltd 3 4 package testutils 5 6 import ( 7 "bytes" 8 "sort" 9 "testing" 10 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func AssertBytesEqual(t *testing.T, a, b [][]byte, ignoreOrder bool) { 15 t.Helper() 16 if ignoreOrder { 17 sl := make([][]byte, len(a)) 18 copy(sl, a) 19 a = sl 20 sort.Slice(a, func(i, j int) bool { 21 return bytes.Compare(a[i], a[j]) == -1 22 }) 23 sl = make([][]byte, len(b)) 24 copy(sl, b) 25 b = sl 26 sort.Slice(b, func(i, j int) bool { 27 return bytes.Compare(b[i], b[j]) == -1 28 }) 29 } 30 assert.Equal(t, a, b) 31 }