From 677e080dfed1f17de76d4914cf4935b4914e9ddb Mon Sep 17 00:00:00 2001 From: aimuz Date: Mon, 5 Aug 2024 03:00:42 +0000 Subject: bytes, strings: replace reflect.DeepEqual and custom eq with slices.Equal in tests Change-Id: I016672af79d49a00ddc2d0449cdaac61e98b4ba0 GitHub-Last-Rev: 38d15d9a03e5bd29e4b25f1d767e40cf7165a7a6 GitHub-Pull-Request: golang/go#68730 Reviewed-on: https://go-review.googlesource.com/c/go/+/602698 LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer Commit-Queue: Ian Lance Taylor Reviewed-by: Ian Lance Taylor --- src/bytes/bytes_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/bytes/bytes_test.go') diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go index 94301358e0..6fb6140c18 100644 --- a/src/bytes/bytes_test.go +++ b/src/bytes/bytes_test.go @@ -10,7 +10,6 @@ import ( "internal/testenv" "math" "math/rand" - "reflect" "slices" "strings" "testing" @@ -814,8 +813,8 @@ func TestSplit(t *testing.T) { t.Errorf(`Join(Split(%q, %q, %d), %q) = %q`, tt.s, tt.sep, tt.n, tt.sep, s) } if tt.n < 0 { - b := Split([]byte(tt.s), []byte(tt.sep)) - if !reflect.DeepEqual(a, b) { + b := sliceOfString(Split([]byte(tt.s), []byte(tt.sep))) + if !slices.Equal(result, b) { t.Errorf("Split disagrees withSplitN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a) } } @@ -869,8 +868,8 @@ func TestSplitAfter(t *testing.T) { t.Errorf(`Join(Split(%q, %q, %d), %q) = %q`, tt.s, tt.sep, tt.n, tt.sep, s) } if tt.n < 0 { - b := SplitAfter([]byte(tt.s), []byte(tt.sep)) - if !reflect.DeepEqual(a, b) { + b := sliceOfString(SplitAfter([]byte(tt.s), []byte(tt.sep))) + if !slices.Equal(result, b) { t.Errorf("SplitAfter disagrees withSplitAfterN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a) } } -- cgit v1.3