2024-10-17 16:16:37 +01:00
|
|
|
// Copyright 2024 New Vector Ltd.
|
|
|
|
//
|
2024-10-18 15:14:08 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
// Please see LICENSE files in the repository root for full details.
|
2018-07-26 17:34:39 +01:00
|
|
|
|
|
|
|
package test
|
|
|
|
|
|
|
|
import "sort"
|
|
|
|
|
|
|
|
// UnsortedStringSliceEqual returns true if the slices have same length & elements.
|
|
|
|
// Does not modify the given slice.
|
|
|
|
func UnsortedStringSliceEqual(first, second []string) bool {
|
|
|
|
if len(first) != len(second) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
a, b := first[:], second[:]
|
|
|
|
sort.Strings(a)
|
|
|
|
sort.Strings(b)
|
|
|
|
for i := range a {
|
|
|
|
if a[i] != b[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|