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

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