@@ -52,6 +52,22 @@ func TestUnique(t *testing.T) {
52
52
slice .Unique ([]string {
53
53
"a" , "a" , "a" ,
54
54
}))
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
+ }))
55
71
}
56
72
57
73
func TestContains (t * testing.T ) {
@@ -230,4 +246,15 @@ func TestSymmetricDifference(t *testing.T) {
230
246
require .ElementsMatch (t , []int {1 , 2 , 3 }, add )
231
247
require .ElementsMatch (t , []int {}, remove )
232
248
})
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
+ })
233
260
}
0 commit comments