From f3db0df7b6962622816007a49ce7c5c39d887374 Mon Sep 17 00:00:00 2001 From: James Munnelly Date: Fri, 3 Nov 2017 23:58:25 +0000 Subject: [PATCH] Add RemoveDuplicates unit test --- pkg/util/filter_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkg/util/filter_test.go diff --git a/pkg/util/filter_test.go b/pkg/util/filter_test.go new file mode 100644 index 000000000..29a6e99ef --- /dev/null +++ b/pkg/util/filter_test.go @@ -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 + } + } +}