github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/kv/loop/group/api_test.go (about)

     1  package group
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/m4gshm/gollections/convert/as"
     7  	"github.com/m4gshm/gollections/loop"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func Test_group_odd_even(t *testing.T) {
    13  
    14  	var (
    15  		even   = func(v int) bool { return v%2 == 0 }
    16  		groups = Of(loop.KeyValue(loop.Of(1, 1, 2, 4, 3, 1), even, as.Is[int]))
    17  	)
    18  	assert.Equal(t, map[bool][]int{false: {1, 1, 3, 1}, true: {2, 4}}, groups)
    19  }