"encoding/hex"
"math/big"
"reflect"
+ "slices"
"strings"
"testing"
"time"
if len(rest) != 0 {
t.Error("Unmarshal returned extra garbage")
}
- if !reflect.DeepEqual(expectedOrder, resultStruct.Strings) {
+ if !slices.Equal(expectedOrder, resultStruct.Strings) {
t.Errorf("Unexpected SET content. got: %s, want: %s", resultStruct.Strings, expectedOrder)
}
}
"fmt"
"io"
"reflect"
+ "slices"
"strings"
"testing"
"unicode/utf8"
}
break
}
- if got, want := rec, tt.Output[recNum]; !reflect.DeepEqual(got, want) {
+ if got, want := rec, tt.Output[recNum]; !slices.Equal(got, want) {
t.Errorf("Read vs ReadAll mismatch;\ngot %q\nwant %q", got, want)
}
pos := positions[recNum]
"encoding/hex"
"fmt"
"io"
+ "maps"
"math"
"reflect"
"slices"
res := make([]int8, 9)
dec.Decode(&res)
- if !reflect.DeepEqual(s8, res) {
+ if !slices.Equal(s8, res) {
t.Fatalf("EncodeIntSlice: expected %v, got %v", s8, res)
}
})
res := make([]int16, 9)
dec.Decode(&res)
- if !reflect.DeepEqual(s16, res) {
+ if !slices.Equal(s16, res) {
t.Fatalf("EncodeIntSlice: expected %v, got %v", s16, res)
}
})
res := make([]int32, 9)
dec.Decode(&res)
- if !reflect.DeepEqual(s32, res) {
+ if !slices.Equal(s32, res) {
t.Fatalf("EncodeIntSlice: expected %v, got %v", s32, res)
}
})
res := make([]int64, 9)
dec.Decode(&res)
- if !reflect.DeepEqual(s64, res) {
+ if !slices.Equal(s64, res) {
t.Fatalf("EncodeIntSlice: expected %v, got %v", s64, res)
}
})
if err != nil {
t.Fatal("decode:", err)
}
- if !reflect.DeepEqual(in, out) {
+ if !maps.Equal(in, out) {
t.Errorf("mismatch: %v %v", in, out)
}
}
if err != nil {
t.Fatal("ints: decode:", err)
}
- if !reflect.DeepEqual(x, y) {
+ if !slices.Equal(x, y) {
t.Errorf("ints: expected %q got %q\n", x, y)
}
if addr != &y[0] {
got := readMap(out)
want := readMap(in)
- if !reflect.DeepEqual(got, want) {
+ if !slices.Equal(got, want) {
t.Fatalf("\nEncode: %v\nDecode: %v", want, got)
}
}
"errors"
"fmt"
"image"
+ "maps"
"math"
"math/big"
"net"
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)
}
}
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)
}
}
// Prior to CVE-2022-24675, this input would cause a stack overflow.
input := []byte(strings.Repeat("-----BEGIN \n", 10000000))
result, rest := Decode(input)
- if result != nil || !reflect.DeepEqual(rest, input) {
+ if result != nil || !bytes.Equal(rest, input) {
t.Errorf("Encode of %#v decoded as %#v", input, rest)
}
}