mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-31 15:08:42 -04: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
@ -2,6 +2,7 @@ package encode
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -112,7 +113,7 @@ func TestPreferOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
enc.Prefer = test.prefer
|
enc.Prefer = test.prefer
|
||||||
result := AcceptedEncodings(r, enc.Prefer)
|
result := AcceptedEncodings(r, enc.Prefer)
|
||||||
if !sliceEqual(result, test.expected) {
|
if !slices.Equal(result, test.expected) {
|
||||||
t.Errorf("AcceptedEncodings() actual: %s expected: %s",
|
t.Errorf("AcceptedEncodings() actual: %s expected: %s",
|
||||||
result,
|
result,
|
||||||
test.expected)
|
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) {
|
func TestValidate(t *testing.T) {
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user