mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
refactor: use slices.Equal to simplify code (#7141)
Signed-off-by: minxinyi <minxinyi6@outlook.com>
This commit is contained in:
parent
6de2c9e135
commit
ab3b2d64ba
1 changed files with 2 additions and 12 deletions
|
@ -2,6 +2,7 @@ package encode
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
@ -112,7 +113,7 @@ func TestPreferOrder(t *testing.T) {
|
|||
}
|
||||
enc.Prefer = test.prefer
|
||||
result := AcceptedEncodings(r, enc.Prefer)
|
||||
if !sliceEqual(result, test.expected) {
|
||||
if !slices.Equal(result, test.expected) {
|
||||
t.Errorf("AcceptedEncodings() actual: %s expected: %s",
|
||||
result,
|
||||
test.expected)
|
||||
|
@ -121,17 +122,6 @@ func TestPreferOrder(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func sliceEqual(a, b []string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
type testCase struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue