mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
16 lines
347 B
Go
16 lines
347 B
Go
package underscore_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
u "github.com/rjNemo/underscore"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFlatmap(t *testing.T) {
|
|
nums := []int{1, 2, 3, 4}
|
|
transform := func(n int) []int { return []int{(n - 1) * n, (n) * n} }
|
|
want := []int{0, 1, 2, 4, 6, 9, 12, 16}
|
|
|
|
assert.Equal(t, want, u.Flatmap(nums, transform))
|
|
}
|