diff options
| author | apocelipes <seve3r@outlook.com> | 2024-07-24 10:32:38 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-07-25 00:23:58 +0000 |
| commit | b5b9d24dc38c63cca6319f2b139cb9b35b3cb058 (patch) | |
| tree | b7c62fd2f47432d0e281c3ecc0c291915658218d /src/encoding/json | |
| parent | 05861ff90cfc855620d0dcbd1d6cc488ebf04880 (diff) | |
| download | go-b5b9d24dc38c63cca6319f2b139cb9b35b3cb058.tar.xz | |
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 <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>
Diffstat (limited to 'src/encoding/json')
| -rw-r--r-- | src/encoding/json/decode_test.go | 5 |
1 files changed, 3 insertions, 2 deletions
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) } } |
