1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 16:42:41 +08:00
Files
go-mixed/collections/generics/sort_map_test.go
2022-04-22 17:17:02 +08:00

46 lines
676 B
Go

package generics
import (
"fmt"
"testing"
)
func TestSort(t *testing.T) {
m := map[string]any{
"Bcd": "bcd",
"Abc": "abc",
}
t.Log(NewSortMap(m).Values())
t.Log(NewSortMap(m).Desc().Values())
t.Log(NewSortMap(m).Asc().Values())
}
func TestMapSortInt(t *testing.T) {
m := map[string]int{
"Bcd": 8,
"Abc": 4,
}
ret := NewSortMap(m).Desc().Values()
t.Log(NewSortMap(m).Desc())
t.Log(NewSortMap(m).Asc())
t.Log(ret)
}
func TestJoin(t *testing.T) {
m := map[string]any{
"Bcd": "bcd",
"Abc": "abc",
"Efg": "efg",
}
t.Log(m)
j := NewSortMap(m).Asc().Join("&", func(k string, v any) string {
return fmt.Sprintf("%s=%v", k, v)
})
t.Log(j)
}