1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-05-12 11:32:03 +08:00
parent 7930a64e59
commit 08309e4a49
7 changed files with 85 additions and 37 deletions

View File

@ -3,6 +3,8 @@ package maps
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSortMapConvert(t *testing.T) {
@ -16,9 +18,17 @@ func TestSortMapConvert(t *testing.T) {
}
func TestSortedJoin(t *testing.T) {
var m = NewSortedMap(map[string]any{"b": "b", "a": "a", "d": "d", "c": "c"}).Asc()
m := NewSortedMap(map[string]any{"b": "b", "a": "a", "d": "d", "c": "c"}).Asc()
t.Log(Join[string, any](m, "&", func(k string, v any) string {
f := func(k string, v any) string {
return fmt.Sprintf("%s=%v", k, v)
}))
}
ret := Join[string, any](m, "&", f)
assert.Equal(t, ret, "a=a&b=b&c=c&d=d")
ret = Join[string, any](m.Desc(), "&", f)
assert.Equal(t, "d=d&c=c&b=b&a=a", ret)
}