Add RemoveDuplicates unit test

This commit is contained in:
James Munnelly 2017-11-03 23:58:25 +00:00
parent 6ac437699d
commit f3db0df7b6

36
pkg/util/filter_test.go Normal file
View 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
}
}
}