github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/math/variance_sample_test.go (about)

     1  package math_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/MontFerret/ferret/pkg/runtime/values"
     8  	"github.com/MontFerret/ferret/pkg/stdlib/math"
     9  
    10  	. "github.com/smartystreets/goconvey/convey"
    11  )
    12  
    13  func TestSampleVariance(t *testing.T) {
    14  	Convey("Should return a value", t, func() {
    15  		out, err := math.SampleVariance(
    16  			context.Background(),
    17  			values.NewArrayWith(
    18  				values.NewInt(1),
    19  				values.NewInt(3),
    20  				values.NewInt(6),
    21  				values.NewInt(5),
    22  				values.NewInt(2),
    23  			),
    24  		)
    25  
    26  		So(err, ShouldBeNil)
    27  		So(out.Unwrap(), ShouldEqual, 4.3)
    28  	})
    29  }