github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/min_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_Min(t *testing.T) { 10 test := []struct { 11 name string 12 args []interface{} 13 expected int 14 }{ 15 { 16 name: "min of empty slice", 17 args: []interface{}{ 18 []int{}, 19 }, 20 expected: 0, 21 }, 22 { 23 name: "min of slice", 24 args: []interface{}{ 25 []int{1, 2, 3}, 26 }, 27 expected: 1, 28 }, 29 { 30 name: "min of slice with negative numbers", 31 args: []interface{}{ 32 []int{-1, -2, -3}, 33 }, 34 expected: -3, 35 }, 36 { 37 name: "min of slice with negative and positive numbers", 38 args: []interface{}{ 39 []int{-1, 2, -3}, 40 }, 41 expected: -3, 42 }, 43 { 44 name: "min of comma separated numbers", 45 args: []interface{}{ 46 1, 2, 3, 4, 5, 47 }, 48 expected: 1, 49 }, 50 } 51 52 for _, tt := range test { 53 t.Run(tt.name, func(t *testing.T) { 54 actual := Min(tt.args...) 55 assert.Equal(t, tt.expected, actual) 56 }) 57 } 58 }