mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-05 12:58:45 +00:00
make EqualStringSlice to generic EqualSliceValues (#2179)
just a fly-by refactoring
This commit is contained in:
@@ -27,3 +27,34 @@ func TestMergeSlices(t *testing.T) {
|
||||
resultIS := MergeSlices([]int{}, []int{1, 2}, []int{4}, nil)
|
||||
assert.EqualValues(t, []int{1, 2, 4}, resultIS)
|
||||
}
|
||||
|
||||
func TestEqualSliceValues(t *testing.T) {
|
||||
tests := []struct {
|
||||
in1 []string
|
||||
in2 []string
|
||||
out bool
|
||||
}{{
|
||||
in1: []string{"", "ab", "12", "ab"},
|
||||
in2: []string{"12", "ab"},
|
||||
out: false,
|
||||
}, {
|
||||
in1: nil,
|
||||
in2: nil,
|
||||
out: true,
|
||||
}, {
|
||||
in1: []string{"AA", "AA", "2", " "},
|
||||
in2: []string{"2", "AA", " ", "AA"},
|
||||
out: true,
|
||||
}, {
|
||||
in1: []string{"AA", "AA", "2", " "},
|
||||
in2: []string{"2", "2", " ", "AA"},
|
||||
out: false,
|
||||
}}
|
||||
|
||||
for _, tc := range tests {
|
||||
assert.EqualValues(t, tc.out, EqualSliceValues(tc.in1, tc.in2), "could not correctly process input: '%#v', %#v", tc.in1, tc.in2)
|
||||
}
|
||||
|
||||
assert.True(t, EqualSliceValues([]bool{true, false, false}, []bool{false, false, true}))
|
||||
assert.False(t, EqualSliceValues([]bool{true, false, false}, []bool{true, false, true}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user