Initial commit of modash
This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
commit
a20530ddfd
20 changed files with 425 additions and 0 deletions
28
momap/toslice_test.go
Normal file
28
momap/toslice_test.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package momap_test
|
||||
|
||||
import (
|
||||
"lmika.dev/pkg/modash/momap"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestToSlice(t *testing.T) {
|
||||
type pair struct {
|
||||
left int
|
||||
right string
|
||||
}
|
||||
|
||||
ms := map[int]string{
|
||||
1: "one",
|
||||
2: "two",
|
||||
3: "three",
|
||||
}
|
||||
|
||||
pairs := momap.ToSlice(ms, func(k int, v string) pair { return pair{k, v} })
|
||||
|
||||
assert.Len(t, pairs, 3)
|
||||
assert.Contains(t, pairs, pair{1, "one"})
|
||||
assert.Contains(t, pairs, pair{2, "two"})
|
||||
assert.Contains(t, pairs, pair{3, "three"})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue