From c0eac35a4cd3ca16d3d1fc153a155b0b18f49633 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Wed, 24 Jul 2024 10:32:22 +0000 Subject: bytes,strings,unicode/utf16: use slices to clean up tests Replace reflect.DeepEqual with slices.Equal, which is much faster. Remove some redundant helper functions. Change-Id: I51b32a3d0c3fc5ad0d3b6ff0dd03f39c507e5762 GitHub-Last-Rev: e21f46d4a026b6bf6e8d912dfb8d361a20a4e779 GitHub-Pull-Request: golang/go#67609 Reviewed-on: https://go-review.googlesource.com/c/go/+/587937 Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Commit-Queue: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Griesemer --- src/unicode/utf16/utf16_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/unicode') diff --git a/src/unicode/utf16/utf16_test.go b/src/unicode/utf16/utf16_test.go index 74a4a6746b..3d434275af 100644 --- a/src/unicode/utf16/utf16_test.go +++ b/src/unicode/utf16/utf16_test.go @@ -6,7 +6,7 @@ package utf16_test import ( "internal/testenv" - "reflect" + "slices" "testing" "unicode" . "unicode/utf16" @@ -58,7 +58,7 @@ var encodeTests = []encodeTest{ func TestEncode(t *testing.T) { for _, tt := range encodeTests { out := Encode(tt.in) - if !reflect.DeepEqual(out, tt.out) { + if !slices.Equal(out, tt.out) { t.Errorf("Encode(%x) = %x; want %x", tt.in, out, tt.out) } } @@ -70,7 +70,7 @@ func TestAppendRune(t *testing.T) { for _, u := range tt.in { out = AppendRune(out, u) } - if !reflect.DeepEqual(out, tt.out) { + if !slices.Equal(out, tt.out) { t.Errorf("AppendRune(%x) = %x; want %x", tt.in, out, tt.out) } } @@ -143,7 +143,7 @@ func TestAllocationsDecode(t *testing.T) { func TestDecode(t *testing.T) { for _, tt := range decodeTests { out := Decode(tt.in) - if !reflect.DeepEqual(out, tt.out) { + if !slices.Equal(out, tt.out) { t.Errorf("Decode(%x) = %x; want %x", tt.in, out, tt.out) } } -- cgit v1.3