modash/momap/toslice_test.go

29 lines
498 B
Go
Raw Normal View History

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"})
}