github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/break/kv/loop/group/api_test.go (about) 1 package group 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/m4gshm/gollections/break/loop" 9 ) 10 11 func Test_group_odd_even(t *testing.T) { 12 13 var ( 14 even = func(v int) (bool, error) { return v%2 == 0, nil } 15 groups, _ = Of(loop.KeyValuee(loop.Of(1, 1, 2, 4, 3, 1), even, func(i int) (int, error) { return i, nil })) 16 ) 17 assert.Equal(t, map[bool][]int{false: {1, 1, 3, 1}, true: {2, 4}}, groups) 18 }