github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/bool_test.go (about)

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_Bool(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		args     []interface{}
    13  		expected bool
    14  	}{
    15  		{
    16  			name:     "Bool with true",
    17  			args:     []interface{}{true},
    18  			expected: true,
    19  		},
    20  		{
    21  			name:     "Bool with false",
    22  			args:     []interface{}{false},
    23  			expected: false,
    24  		},
    25  		{
    26  			name:     "Bool with 1",
    27  			args:     []interface{}{1},
    28  			expected: true,
    29  		},
    30  		{
    31  			name:     "Bool with 0",
    32  			args:     []interface{}{0},
    33  			expected: false,
    34  		},
    35  		{
    36  			name:     "Bool with true string",
    37  			args:     []interface{}{"true"},
    38  			expected: true,
    39  		},
    40  		{
    41  			name:     "Bool with false string",
    42  			args:     []interface{}{"false"},
    43  			expected: false,
    44  		},
    45  		{
    46  			name:     "Bool with 1 string",
    47  			args:     []interface{}{"1"},
    48  			expected: true,
    49  		},
    50  		{
    51  			name:     "Bool with 0 string",
    52  			args:     []interface{}{"0"},
    53  			expected: false,
    54  		},
    55  	}
    56  
    57  	for _, tt := range tests {
    58  		t.Run(tt.name, func(t *testing.T) {
    59  			got := Bool(tt.args...)
    60  			assert.Equal(t, tt.expected, got)
    61  		})
    62  	}
    63  }