aboutsummaryrefslogtreecommitdiff
path: root/src/strings/strings_test.go
diff options
context:
space:
mode:
authoraimuz <mr.imuz@gmail.com>2024-08-05 03:00:42 +0000
committerGopher Robot <gobot@golang.org>2024-08-05 18:44:21 +0000
commit677e080dfed1f17de76d4914cf4935b4914e9ddb (patch)
tree227a9c520a83b22f22bfc56c21cbdd75a651b1dc /src/strings/strings_test.go
parentd465aee0b80b8eb0b63929deb8de0b21187c59a7 (diff)
downloadgo-677e080dfed1f17de76d4914cf4935b4914e9ddb.tar.xz
bytes, strings: replace reflect.DeepEqual and custom eq with slices.Equal in tests
Change-Id: I016672af79d49a00ddc2d0449cdaac61e98b4ba0 GitHub-Last-Rev: 38d15d9a03e5bd29e4b25f1d767e40cf7165a7a6 GitHub-Pull-Request: golang/go#68730 Reviewed-on: https://go-review.googlesource.com/c/go/+/602698 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/strings/strings_test.go')
-rw-r--r--src/strings/strings_test.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go
index 4c8c25ee13..c918372280 100644
--- a/src/strings/strings_test.go
+++ b/src/strings/strings_test.go
@@ -19,18 +19,6 @@ import (
"unsafe"
)
-func eq(a, b []string) bool {
- if len(a) != len(b) {
- return false
- }
- for i := 0; i < len(a); i++ {
- if a[i] != b[i] {
- return false
- }
- }
- return true
-}
-
var abcd = "abcd"
var faces = "☺☻☹"
var commas = "1,2,3,4"
@@ -418,7 +406,7 @@ var splittests = []SplitTest{
func TestSplit(t *testing.T) {
for _, tt := range splittests {
a := SplitN(tt.s, tt.sep, tt.n)
- if !eq(a, tt.a) {
+ if !slices.Equal(a, tt.a) {
t.Errorf("Split(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, a, tt.a)
continue
}
@@ -457,7 +445,7 @@ var splitaftertests = []SplitTest{
func TestSplitAfter(t *testing.T) {
for _, tt := range splitaftertests {
a := SplitAfterN(tt.s, tt.sep, tt.n)
- if !eq(a, tt.a) {
+ if !slices.Equal(a, tt.a) {
t.Errorf(`Split(%q, %q, %d) = %v; want %v`, tt.s, tt.sep, tt.n, a, tt.a)
continue
}
@@ -500,7 +488,7 @@ var fieldstests = []FieldsTest{
func TestFields(t *testing.T) {
for _, tt := range fieldstests {
a := Fields(tt.s)
- if !eq(a, tt.a) {
+ if !slices.Equal(a, tt.a) {
t.Errorf("Fields(%q) = %v; want %v", tt.s, a, tt.a)
continue
}
@@ -517,7 +505,7 @@ var FieldsFuncTests = []FieldsTest{
func TestFieldsFunc(t *testing.T) {
for _, tt := range fieldstests {
a := FieldsFunc(tt.s, unicode.IsSpace)
- if !eq(a, tt.a) {
+ if !slices.Equal(a, tt.a) {
t.Errorf("FieldsFunc(%q, unicode.IsSpace) = %v; want %v", tt.s, a, tt.a)
continue
}
@@ -525,7 +513,7 @@ func TestFieldsFunc(t *testing.T) {
pred := func(c rune) bool { return c == 'X' }
for _, tt := range FieldsFuncTests {
a := FieldsFunc(tt.s, pred)
- if !eq(a, tt.a) {
+ if !slices.Equal(a, tt.a) {
t.Errorf("FieldsFunc(%q) = %v, want %v", tt.s, a, tt.a)
}
}