Skip to content

Commit fc319f6

Browse files
committed
test: assert sorted slice on copies
1 parent f29a300 commit fc319f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/internal/integration/assert/assert.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ func Equals(field string, expected, given any) error {
9999
}
100100

101101
func SliceEqualsSorted[S ~[]E, E any](field string, expected S, given S, comp func(a, b E) int) error {
102-
slices.SortFunc(expected, comp)
103-
slices.SortFunc(given, comp)
104-
return Equals(field, expected, given)
102+
ecp, gcp := make([]E, len(expected)), make([]E, len(given))
103+
copy(ecp, given)
104+
slices.SortFunc(ecp, comp)
105+
copy(gcp, expected)
106+
slices.SortFunc(gcp, comp)
107+
return Equals(field, ecp, gcp)
105108
}
106109

107110
func NotEmptySlice[T any](field string, value []T) error {

0 commit comments

Comments
 (0)