forked from ahmetb/go-linq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip_test.go
More file actions
26 lines (21 loc) · 737 Bytes
/
zip_test.go
File metadata and controls
26 lines (21 loc) · 737 Bytes
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
package linq
import "testing"
func TestZip(t *testing.T) {
input1 := []int{1, 2, 3}
input2 := []int{2, 4, 5, 1}
want := []interface{}{3, 6, 8}
if q := From(input1).Zip(From(input2), func(i, j interface{}) interface{} {
return i.(int) + j.(int)
}); !validateQuery(q, want) {
t.Errorf("From(%v).Zip(%v)=%v expected %v", input1, input2, toSlice(q), want)
}
}
func TestZipT_PanicWhenResultSelectorFnIsInvalid(t *testing.T) {
mustPanicWithError(t, "ZipT: parameter [resultSelectorFn] has a invalid function signature. Expected: 'func(T,T)T', actual: 'func(int,int,int)int'", func() {
input1 := []int{1, 2, 3}
input2 := []int{2, 4, 5, 1}
From(input1).ZipT(From(input2), func(i, j, k int) int {
return i + j
})
})
}