1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
package dedupe_test
import (
"reflect"
"testing"
"github.com/nicholas-fedor/shoutrrr/internal/dedupe"
)
func TestRemoveDuplicates(t *testing.T) {
tests := map[string]struct {
input []string
want []string
}{
"no duplicates": {
input: []string{"a", "b", "c"},
want: []string{"a", "b", "c"},
},
"duplicate inside slice": {
input: []string{"a", "b", "a", "c"},
want: []string{"a", "b", "c"},
},
"duplicate at end of slice": {
input: []string{"a", "b", "c", "a"},
want: []string{"a", "b", "c"},
},
"duplicate next to each other inside slice": {
input: []string{"a", "b", "b", "c"},
want: []string{"a", "b", "c"},
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
got := dedupe.RemoveDuplicates(tc.input)
if !reflect.DeepEqual(tc.want, got) {
t.Fatalf("expected: %#v, got: %#v", tc.want, got)
}
})
}
}
|