github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/mapexamples/map_Conv_test.go (about) 1 package mapexamples 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/m4gshm/gollections/map_" 9 ) 10 11 func Test_Conv(t *testing.T) { 12 13 var employers = map[string]map[string]string{ 14 "devops": {"name": "Bob"}, 15 "jun": {"name": "Tom"}, 16 } 17 18 var all, err = map_.Conv(employers, func(title string, employer map[string]string) (string, string, error) { 19 return string([]rune(title)[0]), employer["name"], nil 20 }) 21 //map[d:Bob j:Tom], nil 22 23 assert.Equal(t, map[string]string{"d": "Bob", "j": "Tom"}, all) 24 assert.Nil(t, err) 25 26 }