underscore/flatmap_test.go
Ruidy c53d46816f
refactor: migrate to Go 1.22 slices/cmp, update linters
Replace usage of golang.org/x/exp/constraints with Go 1.22 cmp/slices.
Update .golangci.yml to new v2 format and enable gofmt/goimports.
Refactor imports and type constraints across codebase for consistency.
2025-09-01 23:08:10 -04:00

17 lines
348 B
Go

package underscore_test
import (
"testing"
"github.com/stretchr/testify/assert"
u "github.com/rjNemo/underscore"
)
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))
}