mirror of
https://github.com/samber/lo.git
synced 2025-10-28 02:11:29 +08:00
adding lop.Map and lop.ForEach
This commit is contained in:
24
parallel/slice_test.go
Normal file
24
parallel/slice_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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"})
|
||||
}
|
||||
Reference in New Issue
Block a user