mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 12:05:58 +08:00
1
This commit is contained in:
@@ -46,5 +46,39 @@ func TestIndexOf(t *testing.T) {
|
||||
func TestSort(t *testing.T) {
|
||||
arr := []int{1, 1, 1, 4, 4, 5, 2, 3, 3, 3, 6}
|
||||
fmt.Println(Sort(arr, false))
|
||||
}
|
||||
|
||||
func TestBothExist(t *testing.T) {
|
||||
arr1 := []int{1, 1, 1, 4, 4, 5, 2, 3, 3, 3, 6}
|
||||
arr2 := []int{6, 1, 3}
|
||||
arr3 := []int{5, 1, 3, 6}
|
||||
fmt.Println(BothExist(arr1, arr2, arr3))
|
||||
}
|
||||
|
||||
func TestCompleteAny(t *testing.T) {
|
||||
type Item struct {
|
||||
ID int
|
||||
Value string
|
||||
}
|
||||
|
||||
ids := []int{1, 2, 3, 4, 5, 6, 7, 8}
|
||||
|
||||
var list []Item
|
||||
|
||||
for _, id := range ids {
|
||||
list = append(list, Item{
|
||||
ID: id,
|
||||
Value: fmt.Sprintf("%d", id*1000),
|
||||
})
|
||||
}
|
||||
|
||||
list = DeleteAt(list, -1)
|
||||
ids = DeleteAt(ids, -1)
|
||||
|
||||
ok := CompleteAny(ids, list, func(t Item) int {
|
||||
return t.ID
|
||||
})
|
||||
|
||||
fmt.Printf("%+v\n", ok)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user