1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB
Go

package history
import (
"reflect"
"testing"
)
func Test_Dedupe(t *testing.T) {
for i, tt := range []struct {
orig []string
exp []string
}{
{
orig: nil,
exp: nil,
},
{
orig: []string{"foo"},
exp: []string{"foo"},
},
{
orig: []string{"foo", "bar"},
exp: []string{"foo", "bar"},
},
{
orig: []string{"foo", "bar", "foo"},
exp: []string{"foo", "bar", "foo"},
},
{
orig: []string{"foo", "foo", "foo"},
exp: []string{"foo"},
},
{
orig: []string{"foo", "foo", "foo", "bar", "bar", "bar"},
exp: []string{"foo", "bar"},
},
{
orig: []string{"foo", "bar", "foo", "foo"},
exp: []string{"foo", "bar", "foo"},
},
{
orig: []string{"foo", "foo", "bar", "foo", "foo"},
exp: []string{"foo", "bar", "foo"},
},
{
orig: []string{"foo", "foo", "bar", "foo", "foo", "qux"},
exp: []string{"foo", "bar", "foo", "qux"},
},
{
orig: []string{"foo", "foo", "bar", "bar", "foo", "foo", "qux"},
exp: []string{"foo", "bar", "foo", "qux"},
},
} {
got := Dedupe(tt.orig)
if !reflect.DeepEqual(tt.exp, got) {
t.Fatalf("test %d failed, exp %s, got %s", i, tt.exp, got)
}
}
return
}