Skip to content

Commit ab3b2d6

Browse files
authored
refactor: use slices.Equal to simplify code (#7141)
Signed-off-by: minxinyi <minxinyi6@outlook.com>
1 parent 6de2c9e commit ab3b2d6

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

modules/caddyhttp/encode/encode_test.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package encode
22

33
import (
44
"net/http"
5+
"slices"
56
"sync"
67
"testing"
78
)
@@ -112,7 +113,7 @@ func TestPreferOrder(t *testing.T) {
112113
}
113114
enc.Prefer = test.prefer
114115
result := AcceptedEncodings(r, enc.Prefer)
115-
if !sliceEqual(result, test.expected) {
116+
if !slices.Equal(result, test.expected) {
116117
t.Errorf("AcceptedEncodings() actual: %s expected: %s",
117118
result,
118119
test.expected)
@@ -121,17 +122,6 @@ func TestPreferOrder(t *testing.T) {
121122
}
122123
}
123124

124-
func sliceEqual(a, b []string) bool {
125-
if len(a) != len(b) {
126-
return false
127-
}
128-
for i := range a {
129-
if a[i] != b[i] {
130-
return false
131-
}
132-
}
133-
return true
134-
}
135125

136126
func TestValidate(t *testing.T) {
137127
type testCase struct {

0 commit comments

Comments
 (0)