...

Source file src/github.com/thoas/go-funk/operation_test.go

Documentation: github.com/thoas/go-funk

     1  package funk
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestSum(t *testing.T) {
    10  	is := assert.New(t)
    11  
    12  	is.Equal(Sum([]int{1, 2, 3}), 6.0)
    13  	is.Equal(Sum(&[]int{1, 2, 3}), 6.0)
    14  	is.Equal(Sum([]interface{}{1, 2, 3, 0.5}), 6.5)
    15  }
    16  
    17  func TestProduct(t *testing.T) {
    18  	is := assert.New(t)
    19  
    20  	is.Equal(Product([]int{2, 3, 4}), 24.0)
    21  	is.Equal(Product(&[]int{2, 3, 4}), 24.0)
    22  	is.Equal(Product([]interface{}{2, 3, 4, 0.5}), 12.0)
    23  }
    24  

View as plain text