File: dedupe_test.go

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.8.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,332 kB
  • sloc: sh: 61; makefile: 5
file content (41 lines) | stat: -rw-r--r-- 892 bytes parent folder | download
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)
			}
		})
	}
}