...
1
2
3
4
5 package testing
6
7 import (
8 "reflect"
9 "testing"
10 )
11
12 func TestCompareSlices(t *testing.T) {
13 for _, test := range []struct {
14 a, b []int
15 wantEqual bool
16 }{
17 {nil, nil, true},
18 {nil, []int{}, true},
19 {[]int{1, 2}, []int{1, 2}, true},
20 {[]int{1}, []int{1, 2}, false},
21 {[]int{1, 2}, []int{1}, false},
22 {[]int{1, 2}, []int{1, 3}, false},
23 } {
24 _, got := compareSlices(reflect.ValueOf(test.a), reflect.ValueOf(test.b))
25 if got != test.wantEqual {
26 t.Errorf("%v, %v: got %t, want %t", test.a, test.b, got, test.wantEqual)
27 }
28 }
29 }
30
View as plain text