From d9b68fc037a5fdf068c9d3f3d42785ccf12a8928 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Fri, 8 Sep 2023 13:27:42 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=96=B0=E5=A2=9E=20stream.Slice=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/stream/slice_test.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/utils/stream/slice_test.go b/utils/stream/slice_test.go index 41921c8..83e5cac 100644 --- a/utils/stream/slice_test.go +++ b/utils/stream/slice_test.go @@ -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 + }), + ) }