github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/math/percentile_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 TestPercentile(t *testing.T) { 14 Convey("Should return nth percentile value", t, func() { 15 out, err := math.Percentile( 16 context.Background(), 17 values.NewArrayWith( 18 values.NewInt(1), 19 values.NewInt(2), 20 values.NewInt(3), 21 values.NewInt(4), 22 ), 23 values.NewInt(50), 24 ) 25 26 So(err, ShouldBeNil) 27 So(out, ShouldEqual, 2) 28 }) 29 }