Skip to content

Commit

Permalink
Use slices.Equal available in Go 1.21 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsnet authored Dec 8, 2024
1 parent 9802db0 commit 72794ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion jsontext/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net"
"path"
"reflect"
"slices"
"strings"
"testing"
"testing/iotest"
Expand Down Expand Up @@ -65,7 +66,7 @@ func testDecoder(t *testing.T, where jsontest.CasePos, typeName string, td coder
if !equalTokens(tokens, td.tokens) {
t.Fatalf("%s: tokens mismatch:\ngot %v\nwant %v", where, tokens, td.tokens)
}
if !reflect.DeepEqual(pointers, td.pointers) {
if !slices.Equal(pointers, td.pointers) {
t.Fatalf("%s: pointers mismatch:\ngot %q\nwant %q", where, pointers, td.pointers)
}
case "Value":
Expand Down
3 changes: 2 additions & 1 deletion jsontext/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"path"
"reflect"
"slices"
"testing"

"github.com/go-json-experiment/json/internal/jsonflags"
Expand Down Expand Up @@ -57,7 +58,7 @@ func testEncoder(t *testing.T, where jsontest.CasePos, formatName, typeName stri
pointers = append(pointers, enc.StackPointer())
}
}
if !reflect.DeepEqual(pointers, td.pointers) {
if !slices.Equal(pointers, td.pointers) {
t.Fatalf("%s: pointers mismatch:\ngot %q\nwant %q", where, pointers, td.pointers)
}
case "Value":
Expand Down
4 changes: 2 additions & 2 deletions jsontext/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestStateMachine(t *testing.T) {
got = append(got, e.Length())
}
want := []int64(op)
if !reflect.DeepEqual(got, want) {
if !slices.Equal(got, want) {
t.Fatalf("%s: stack lengths mismatch:\ngot %v\nwant %v", sequence, got, want)
}
case appendToken:
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestObjectNamespace(t *testing.T) {
for i := range ns.length() {
gotNames = append(gotNames, string(ns.getUnquoted(i)))
}
if !reflect.DeepEqual(gotNames, wantNames) {
if !slices.Equal(gotNames, wantNames) {
t.Fatalf("%d: objectNamespace = {%v}, want {%v}", i, strings.Join(gotNames, " "), strings.Join(wantNames, " "))
}
}
Expand Down

0 comments on commit 72794ee

Please sign in to comment.