github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/azure/functions/range_test.go (about)

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_Range(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		args     []interface{}
    13  		expected interface{}
    14  	}{
    15  		{
    16  			name: "range for 3 from 1",
    17  			args: []interface{}{
    18  				1,
    19  				3,
    20  			},
    21  			expected: []int{1, 2, 3},
    22  		},
    23  		{
    24  			name: "range with for 10 from 3",
    25  			args: []interface{}{
    26  				3,
    27  				10,
    28  			},
    29  			expected: []int{3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
    30  		},
    31  		{
    32  			name: "range with for 10 from -10",
    33  			args: []interface{}{
    34  				-10,
    35  				10,
    36  			},
    37  			expected: []int{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1},
    38  		},
    39  	}
    40  	for _, tt := range tests {
    41  		t.Run(tt.name, func(t *testing.T) {
    42  			actual := Range(tt.args...)
    43  			assert.Equal(t, tt.expected, actual)
    44  		})
    45  	}
    46  
    47  }