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: 79554baddb
GitHub-Pull-Request: golang/go#67611
Reviewed-on: https://go-review.googlesource.com/c/go/+/587818
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
apocelipes 2024-07-24 10:32:38 +00:00 committed by Gopher Robot
parent 05861ff90c
commit b5b9d24dc3
5 changed files with 16 additions and 12 deletions

View file

@ -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)
}
}