-
Notifications
You must be signed in to change notification settings - Fork 6
/
intersectby_test.go
38 lines (36 loc) · 956 Bytes
/
intersectby_test.go
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
package go2linq
import (
"iter"
"testing"
)
func TestIntersectBy_Planet(t *testing.T) {
type args struct {
first iter.Seq[Planet]
second iter.Seq[Planet]
keySelector func(Planet) Planet
}
tests := []struct {
name string
args args
want iter.Seq[Planet]
}{
// https://learn.microsoft.com/dotnet/csharp/programming-guide/concepts/linq/set-operations#intersect-and-intersectby
{name: "IntersectBy",
args: args{
first: VarToSeq(Mercury, Venus, Earth, Mars, Jupiter),
second: VarToSeq(Mars, Jupiter, Saturn, Uranus, Neptune),
keySelector: Identity[Planet],
},
want: VarToSeq(Mars, Jupiter),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, _ := IntersectBy(tt.args.first, tt.args.second, tt.args.keySelector)
equal, _ := SequenceEqual(got, tt.want)
if !equal {
t.Errorf("IntersectBy() = %v, want %v", StringDef(got), StringDef(tt.want))
}
})
}
}