mirror of
https://github.com/samber/lo.git
synced 2025-09-27 04:15:58 +08:00
25 lines
530 B
Go
25 lines
530 B
Go
package parallel
|
|
|
|
import (
|
|
"testing"
|
|
"strconv"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMap(t *testing.T) {
|
|
is := assert.New(t)
|
|
|
|
result1 := Map[int, string]([]int{1, 2, 3, 4}, func(x int, _ int) string {
|
|
return "Hello"
|
|
})
|
|
result2 := Map[int64, string]([]int64{1, 2, 3, 4}, func(x int64, _ int) string {
|
|
return strconv.FormatInt(x, 10)
|
|
})
|
|
|
|
is.Equal(len(result1), 4)
|
|
is.Equal(len(result2), 4)
|
|
is.Equal(result1, []string{"Hello", "Hello", "Hello", "Hello"})
|
|
is.Equal(result2, []string{"1", "2", "3", "4"})
|
|
}
|