github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/grpc/xds/internal/balancer/priority/utils_test.go (about)

     1  /*
     2   *
     3   * Copyright 2021 gRPC authors.
     4   *
     5   * Licensed under the Apache License, Version 2.0 (the "License");
     6   * you may not use this file except in compliance with the License.
     7   * You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   */
    18  
    19  package priority
    20  
    21  import "testing"
    22  
    23  func TestCompareStringSlice(t *testing.T) {
    24  	tests := []struct {
    25  		name string
    26  		a    []string
    27  		b    []string
    28  		want bool
    29  	}{
    30  		{
    31  			name: "equal",
    32  			a:    []string{"a", "b"},
    33  			b:    []string{"a", "b"},
    34  			want: true,
    35  		},
    36  		{
    37  			name: "not equal",
    38  			a:    []string{"a", "b"},
    39  			b:    []string{"a", "b", "c"},
    40  			want: false,
    41  		},
    42  		{
    43  			name: "both empty",
    44  			a:    nil,
    45  			b:    nil,
    46  			want: true,
    47  		},
    48  		{
    49  			name: "one empty",
    50  			a:    []string{"a", "b"},
    51  			b:    nil,
    52  			want: false,
    53  		},
    54  	}
    55  	for _, tt := range tests {
    56  		t.Run(tt.name, func(t *testing.T) {
    57  			if got := equalStringSlice(tt.a, tt.b); got != tt.want {
    58  				t.Errorf("equalStringSlice(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
    59  			}
    60  		})
    61  	}
    62  }