Add RemoveDuplicates unit test
This commit is contained in:
parent
6ac437699d
commit
f3db0df7b6
36
pkg/util/filter_test.go
Normal file
36
pkg/util/filter_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package util
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRemoveDuplicates(t *testing.T) {
|
||||
type testT struct {
|
||||
input []string
|
||||
output []string
|
||||
}
|
||||
tests := []testT{
|
||||
{
|
||||
input: []string{"a"},
|
||||
output: []string{"a"},
|
||||
},
|
||||
{
|
||||
input: []string{"a", "b"},
|
||||
output: []string{"a", "b"},
|
||||
},
|
||||
{
|
||||
input: []string{"a", "a"},
|
||||
output: []string{"a"},
|
||||
},
|
||||
{
|
||||
input: []string{"a", "b", "a", "a", "c"},
|
||||
output: []string{"a", "b", "c"},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
actualOutput := RemoveDuplicates(test.input)
|
||||
if len(actualOutput) != len(test.output) ||
|
||||
!EqualUnsorted(test.output, actualOutput) {
|
||||
t.Errorf("returned %q for %q but expected %q", actualOutput, test.input, test.output)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user