github.com/khulnasoft-lab/tunnel-db@v0.0.0-20231117205118-74e1113bd007/pkg/utils/strings/strings_test.go (about)

     1  package strings_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/khulnasoft-lab/tunnel-db/pkg/utils/strings"
     9  )
    10  
    11  func TestUnique(t *testing.T) {
    12  	tests := []struct {
    13  		name  string
    14  		input []string
    15  		want  []string
    16  	}{
    17  		{
    18  
    19  			name: "positive test",
    20  			input: []string{
    21  				"test string 1",
    22  				"test string 3",
    23  				"test string 2",
    24  				"test string 1",
    25  				"test string 2",
    26  				"test string 3",
    27  			},
    28  			want: []string{
    29  				"test string 1",
    30  				"test string 2",
    31  				"test string 3",
    32  			},
    33  		},
    34  		{
    35  			name:  "positive test input empty",
    36  			input: []string{},
    37  		},
    38  		{
    39  			name: "positive test input uniq",
    40  			input: []string{
    41  				"test string 1",
    42  				"test string 3",
    43  				"test string 2",
    44  			},
    45  			want: []string{
    46  				"test string 1",
    47  				"test string 2",
    48  				"test string 3",
    49  			},
    50  		},
    51  	}
    52  	for _, tt := range tests {
    53  		actualData := strings.Unique(tt.input)
    54  		assert.Equal(t, actualData, tt.want, tt.name)
    55  	}
    56  
    57  }