github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/arrays/union_distinct_test.go (about) 1 package arrays_test 2 3 import ( 4 "context" 5 "testing" 6 7 . "github.com/smartystreets/goconvey/convey" 8 9 "github.com/MontFerret/ferret/pkg/runtime/values" 10 "github.com/MontFerret/ferret/pkg/stdlib/arrays" 11 ) 12 13 func TestUnionDistinct(t *testing.T) { 14 Convey("Should union all arrays with unique values", t, func() { 15 arr1 := values.NewArrayWith( 16 values.NewInt(1), 17 values.NewInt(2), 18 values.NewInt(3), 19 values.NewInt(4), 20 ) 21 arr2 := values.NewArrayWith( 22 values.NewInt(5), 23 values.NewInt(2), 24 values.NewInt(6), 25 values.NewInt(4), 26 ) 27 28 arr3 := values.NewArrayWith( 29 values.NewString("a"), 30 values.NewString("b"), 31 values.NewString("c"), 32 values.NewString("d"), 33 ) 34 35 arr4 := values.NewArrayWith( 36 values.NewString("e"), 37 values.NewString("b"), 38 values.NewString("f"), 39 values.NewString("d"), 40 ) 41 42 out, err := arrays.UnionDistinct( 43 context.Background(), 44 arr1, 45 arr2, 46 arr3, 47 arr4, 48 ) 49 50 So(err, ShouldBeNil) 51 So(out.String(), ShouldEqual, `[1,2,3,4,5,6,"a","b","c","d","e","f"]`) 52 }) 53 }