test: 新增 stream.Slice 测试用例

This commit is contained in:
kercylan98 2023-09-08 13:27:42 +08:00
parent 62ef35a518
commit d9b68fc037
1 changed files with 25 additions and 5 deletions

View File

@ -5,10 +5,30 @@ import (
"testing"
)
func TestStream_Chunk(t *testing.T) {
func TestStream(t *testing.T) {
var s = stream.Slice[int]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
var chunks = s.Chunk(3)
for _, chunk := range chunks {
t.Log(chunk)
}
t.Log(s, s.
Copy().
Shuffle().
Filter(true, func(index int, item int) bool {
return item%2 == 0
}).
Zoom(20).
Each(true, func(index int, item int) bool {
t.Log(index, item)
return false
}).
Chunk(3).
EachT(func(index int, item stream.Slice[int]) bool {
t.Log(item)
return false
}).
Merge().
FillBy(func(index int, value int) int {
if value == 0 {
return 999
}
return value
}),
)
}