package sliceutil import ( "reflect" "sort" "testing" ) func TestUnique(t *testing.T) { tests := []struct { Name string Test []string Want []string }{ {"nil", nil, nil}, {"single", []string{"test"}, []string{"test"}}, {"duplicate", []string{"test", "test"}, []string{"test"}}, {"multiple", []string{"a", "a", "b", "b", "b", "c"}, []string{"a", "b", "c"}}, } for _, test := range tests { t.Run(test.Name, func(it *testing.T) { v := Unique(test.Test) if v != nil { sort.Strings(v) } if !reflect.DeepEqual(v, test.Want) { it.Errorf("expected unique(%v) to return %v, got %v", test.Test, test.Want, v) } }) } }