github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/sliceexamples/slice_Reduce_test.go (about) 1 package sliceexamples 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/m4gshm/gollections/slice" 9 ) 10 11 func Test_Slice_ReduceSum(t *testing.T) { 12 13 var sum = slice.Reduce([]int{1, 2, 3, 4, 5, 6}, func(i1, i2 int) int { return i1 + i2 }) 14 //21 15 16 assert.Equal(t, 21, sum) 17 }