slice: introduce common Copy helper

It's a bit more convenient to use.
This commit is contained in:
Roman Khimov 2021-07-18 16:32:10 +03:00
parent a54e3516d1
commit 19717dd9a8
14 changed files with 51 additions and 65 deletions

View file

@ -30,8 +30,8 @@ var testCases = []struct {
func TestCopyReverse(t *testing.T) {
for _, tc := range testCases {
arg := make([]byte, len(tc.arr))
copy(arg, tc.arr)
arg := Copy(tc.arr)
require.Equal(t, tc.arr, arg)
have := CopyReverse(arg)
require.Equal(t, tc.rev, have)
@ -44,5 +44,8 @@ func TestCopyReverse(t *testing.T) {
Reverse(arg)
require.Equal(t, tc.rev, arg)
if len(tc.arr) > 1 {
require.NotEqual(t, tc.arr, arg)
}
}
}