github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/equals_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_Equals(t *testing.T) { 10 tests := []struct { 11 name string 12 args []interface{} 13 expected interface{} 14 }{ 15 { 16 name: "equals with nil", 17 args: []interface{}{ 18 nil, 19 }, 20 expected: false, 21 }, 22 { 23 name: "equals with nil and string", 24 args: []interface{}{ 25 nil, 26 "test", 27 }, 28 expected: false, 29 }, 30 { 31 name: "equals with nil and string and int", 32 args: []interface{}{ 33 nil, 34 "test", 35 1, 36 }, 37 expected: false, 38 }, 39 { 40 name: "equals with nil and nil and array", 41 args: []interface{}{ 42 nil, 43 nil, 44 []interface{}{"a", "b", "c"}, 45 }, 46 expected: false, 47 }, 48 { 49 name: "equals with nil and nil", 50 args: []interface{}{ 51 nil, 52 nil, 53 }, 54 expected: true, 55 }, 56 { 57 name: "equals with string and string", 58 args: []interface{}{ 59 "test", 60 "test", 61 }, 62 expected: true, 63 }, 64 { 65 name: "equals with string and string", 66 args: []interface{}{ 67 "test", 68 "test1", 69 }, 70 expected: false, 71 }, 72 { 73 name: "equals with int and int", 74 args: []interface{}{ 75 1, 76 1, 77 }, 78 expected: true, 79 }, 80 { 81 name: "equals with int and int", 82 args: []interface{}{ 83 1, 84 2, 85 }, 86 expected: false, 87 }, 88 { 89 name: "equals with array and array", 90 args: []interface{}{ 91 []interface{}{"a", "b", "c"}, 92 []interface{}{"a", "b", "c"}, 93 }, 94 expected: true, 95 }, 96 { 97 name: "equals with array and array", 98 args: []interface{}{ 99 []interface{}{"a", "b", "c"}, 100 []interface{}{"a", "b", "d"}, 101 }, 102 expected: false, 103 }, 104 } 105 for _, tt := range tests { 106 t.Run(tt.name, func(t *testing.T) { 107 actual := Equals(tt.args...) 108 assert.Equal(t, tt.expected, actual) 109 }) 110 } 111 }