@@ -52,6 +52,22 @@ func TestUnique(t *testing.T) {
5252 slice .Unique ([]string {
5353 "a" , "a" , "a" ,
5454 }))
55+
56+ require .ElementsMatch (t ,
57+ []int {1 , 2 , 3 , 4 , 5 },
58+ slice .UniqueFunc ([]int {
59+ 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 , 4 , 5 ,
60+ }, func (a , b int ) bool {
61+ return a == b
62+ }))
63+
64+ require .ElementsMatch (t ,
65+ []string {"a" },
66+ slice .UniqueFunc ([]string {
67+ "a" , "a" , "a" ,
68+ }, func (a , b string ) bool {
69+ return a == b
70+ }))
5571}
5672
5773func TestContains (t * testing.T ) {
@@ -230,4 +246,15 @@ func TestSymmetricDifference(t *testing.T) {
230246 require .ElementsMatch (t , []int {1 , 2 , 3 }, add )
231247 require .ElementsMatch (t , []int {}, remove )
232248 })
249+
250+ t .Run ("Duplicates" , func (t * testing.T ) {
251+ t .Parallel ()
252+
253+ add , remove := slice .SymmetricDifference (
254+ []int {5 , 5 , 5 , 1 , 1 , 1 , 3 , 3 , 3 , 5 , 5 , 5 },
255+ []int {2 , 2 , 2 , 1 , 1 , 1 , 2 , 4 , 4 , 4 , 5 , 5 , 5 , 1 , 1 },
256+ )
257+ require .ElementsMatch (t , []int {2 , 4 }, add )
258+ require .ElementsMatch (t , []int {3 }, remove )
259+ })
233260}
0 commit comments