From b5b9d24dc38c63cca6319f2b139cb9b35b3cb058 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Wed, 24 Jul 2024 10:32:38 +0000 Subject: encoding: use slices and maps to clean up tests Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is much faster. Change-Id: I62ad60a66e28cfb2bb49c36037bafd4b9d201e88 GitHub-Last-Rev: 79554baddb1856260a44ba6587c205d223a527b1 GitHub-Pull-Request: golang/go#67611 Reviewed-on: https://go-review.googlesource.com/c/go/+/587818 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- src/encoding/json/decode_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/encoding/json/decode_test.go') diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index f5b44677b3..ed90695039 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "image" + "maps" "math" "math/big" "net" @@ -1979,7 +1980,7 @@ func TestStringKind(t *testing.T) { if err != nil { t.Fatalf("Unmarshal error: %v", err) } - if !reflect.DeepEqual(got, want) { + if !maps.Equal(got, want) { t.Fatalf("Marshal/Unmarshal mismatch:\n\tgot: %v\n\twant: %v", got, want) } } @@ -2533,7 +2534,7 @@ func TestUnmarshalRescanLiteralMangledUnquote(t *testing.T) { t.Fatalf("Unmarshal error: %v", err) } want := map[textUnmarshalerString]string{"foo": "", `"`: ""} - if !reflect.DeepEqual(got, want) { + if !maps.Equal(got, want) { t.Errorf("Marshal/Unmarshal roundtrip:\n\tgot: %q\n\twant: %q", gotT, wantT) } } -- cgit v1.3-6-g1900