This commit is contained in:
withchao
2023-02-02 17:49:19 +08:00
parent 94b0e60e83
commit 778e3e5cd2
2 changed files with 211 additions and 52 deletions
+34
View File
@@ -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)
}