github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/math/max_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 TestMax(t *testing.T) { 14 Convey("Should return the largest value", t, func() { 15 out, err := math.Max(context.Background(), values.NewArrayWith( 16 values.NewInt(5), 17 values.NewInt(2), 18 values.NewInt(9), 19 values.NewInt(2), 20 )) 21 22 So(err, ShouldBeNil) 23 So(out, ShouldEqual, 9) 24 25 out, err = math.Max(context.Background(), values.NewArrayWith( 26 values.NewInt(-3), 27 values.NewInt(-5), 28 values.NewInt(2), 29 )) 30 31 So(err, ShouldBeNil) 32 So(out, ShouldEqual, 2) 33 34 out, err = math.Max(context.Background(), values.NewArrayWith( 35 values.None, 36 values.NewInt(-5), 37 values.False, 38 )) 39 40 So(err, ShouldBeNil) 41 So(out, ShouldEqual, values.None) 42 43 out, err = math.Max(context.Background(), values.NewArray(0)) 44 45 So(err, ShouldBeNil) 46 So(out, ShouldEqual, values.None) 47 }) 48 }