github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/split_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_Split(t *testing.T) { 10 tests := []struct { 11 name string 12 args []interface{} 13 expected []string 14 }{ 15 { 16 name: "split a string", 17 args: []interface{}{ 18 "hello, world", 19 ",", 20 }, 21 expected: []string{"hello", " world"}, 22 }, 23 { 24 name: "split a string with multiple separators", 25 args: []interface{}{ 26 "one;two,three", 27 []string{",", ";"}, 28 }, 29 expected: []string{"one", "two", "three"}, 30 }, 31 } 32 for _, tt := range tests { 33 t.Run(tt.name, func(t *testing.T) { 34 actual := Split(tt.args...) 35 assert.Equal(t, tt.expected, actual) 36 }) 37 } 38 }