From 40bfb4af20d5c1eebb12761f8f18573b85a57d1c Mon Sep 17 00:00:00 2001 From: Dima Kossovich Date: Sun, 12 Nov 2023 21:58:21 +0200 Subject: [PATCH] add tests for prefixpipe --- cover.cov | 242 +++++++++++++++++++------------------- coverage_badge.png | Bin 2539 -> 2543 bytes pkg/pipe/pipe_test.go | 63 ++++++++++ pkg/pipies/filters.go | 3 - pkg/pipies/pipies_test.go | 9 +- 5 files changed, 188 insertions(+), 129 deletions(-) diff --git a/cover.cov b/cover.cov index 0fd7ccd..0a70fcb 100644 --- a/cover.cov +++ b/cover.cov @@ -61,11 +61,9 @@ github.com/koss-null/funcfrog/pkg/pipies/filters.go:43.25,45.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:49.61,50.25 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:50.25,52.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/filters.go:59.75,63.25 3 1 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:63.25,64.15 1 1 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:64.15,66.4 1 0 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:67.3,72.28 4 1 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:72.28,74.4 1 1 -github.com/koss-null/funcfrog/pkg/pipies/filters.go:75.3,76.14 2 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:63.25,69.28 4 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:69.28,71.4 1 1 +github.com/koss-null/funcfrog/pkg/pipies/filters.go:72.3,73.14 2 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:7.49,8.24 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:8.24,10.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:14.67,15.31 1 1 @@ -73,6 +71,123 @@ github.com/koss-null/funcfrog/pkg/pipies/not.go:15.31,17.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:21.82,22.37 1 1 github.com/koss-null/funcfrog/pkg/pipies/not.go:22.37,24.3 1 1 github.com/koss-null/funcfrog/pkg/pipies/reducers.go:9.72,12.2 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:12.69,13.19 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:13.19,15.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.2,16.17 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.17,18.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.2,19.18 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.18,20.40 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:20.40,22.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:23.3,23.14 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:26.2,30.13 5 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:39.3,41.14 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:41.14,43.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:45.2,46.15 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:46.15,46.40 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.2,48.38 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.38,49.49 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:49.49,51.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:53.3,53.9 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:56.2,59.44 4 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:62.73,66.16 3 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:67.9,68.50 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:69.9,70.50 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.2,73.15 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.15,74.28 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:74.28,76.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.3,77.28 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.28,79.4 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.3,80.15 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.15,81.9 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:83.3,85.7 3 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:88.2,88.11 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:92.68,93.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:93.62,95.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.2,96.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.62,98.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.2,100.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.62,102.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.2,103.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.62,105.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.2,107.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.62,109.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.2,110.62 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.62,112.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.2,115.64 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.64,117.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.2,118.64 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.64,120.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:121.2,121.21 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:124.38,126.25 2 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:126.25,128.3 1 1 +github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:129.2,129.16 1 1 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:6.50,9.33 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:9.33,10.42 1 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:10.42,13.5 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:14.4,14.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:23.62,26.33 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:26.33,27.42 1 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:27.42,30.5 2 0 +github.com/koss-null/funcfrog/pkg/pipe/collectors.go:31.4,31.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:10.36,12.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:22.58,24.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:33.48,34.36 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:34.36,36.3 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:48.60,50.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:57.40,59.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:64.87,66.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/constructors.go:69.41,71.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:10.43,11.25 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:11.25,14.3 2 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:24.48,25.25 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:25.25,27.3 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:37.53,38.28 1 0 +github.com/koss-null/funcfrog/pkg/pipe/functype.go:38.28,40.3 1 0 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:15.46,17.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:20.52,22.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:27.60,29.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:32.53,34.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:38.42,40.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:43.40,45.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:48.30,50.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:53.28,55.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:59.47,61.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:64.28,66.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:69.31,71.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:75.49,77.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:81.38,83.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:86.48,88.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:91.58,93.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipe.go:96.52,98.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:15.53,17.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:20.59,22.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:27.67,29.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:32.32,34.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:37.30,39.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:43.42,45.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:49.41,51.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:55.54,57.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:61.45,63.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:66.55,68.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:71.65,73.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:76.54,78.2 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:13.15,16.33 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:16.33,17.42 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:17.42,20.5 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:21.4,21.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:33.20,36.33 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:36.33,37.42 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:37.42,40.5 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:41.4,41.20 1 0 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:51.98,53.22 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:53.22,55.3 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:56.2,57.19 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:58.9,59.14 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:60.9,61.29 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:62.10,64.27 2 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:64.27,66.4 1 1 +github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:67.3,67.13 1 1 +github.com/koss-null/funcfrog/pkg/pipe/yeet.go:13.38,15.2 1 1 github.com/koss-null/funcfrog/internal/internalpipe/any.go:7.75,10.54 3 1 github.com/koss-null/funcfrog/internal/internalpipe/any.go:10.54,11.37 1 1 github.com/koss-null/funcfrog/internal/internalpipe/any.go:11.37,13.4 1 1 @@ -297,120 +412,3 @@ github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:50.2,55.29 5 1 github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:55.29,56.37 1 1 github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:56.37,58.4 1 1 github.com/koss-null/funcfrog/internal/internalpipe/yeet.go:62.33,66.2 3 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:12.69,13.19 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:13.19,15.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.2,16.17 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:16.17,18.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.2,19.18 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:19.18,20.40 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:20.40,22.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:23.3,23.14 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:26.2,30.13 5 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:39.3,41.14 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:41.14,43.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:45.2,46.15 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:46.15,46.40 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.2,48.38 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:48.38,49.49 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:49.49,51.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:53.3,53.9 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:56.2,59.44 4 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:62.73,66.16 3 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:67.9,68.50 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:69.9,70.50 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.2,73.15 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:73.15,74.28 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:74.28,76.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.3,77.28 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:77.28,79.4 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.3,80.15 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:80.15,81.9 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:83.3,85.7 3 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:88.2,88.11 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:92.68,93.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:93.62,95.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.2,96.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:96.62,98.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.2,100.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:100.62,102.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.2,103.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:103.62,105.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.2,107.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:107.62,109.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.2,110.62 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:110.62,112.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.2,115.64 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:115.64,117.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.2,118.64 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:118.64,120.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:121.2,121.21 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:124.38,126.25 2 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:126.25,128.3 1 1 -github.com/koss-null/funcfrog/internal/algo/parallel/qsort/qsort.go:129.2,129.16 1 1 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:6.50,9.33 2 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:9.33,10.42 1 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:10.42,13.5 2 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:14.4,14.20 1 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:23.62,26.33 2 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:26.33,27.42 1 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:27.42,30.5 2 0 -github.com/koss-null/funcfrog/pkg/pipe/collectors.go:31.4,31.20 1 0 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:10.36,12.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:22.58,24.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:33.48,34.36 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:34.36,36.3 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:48.60,50.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:57.40,59.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:64.87,66.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/constructors.go:69.41,71.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:10.43,11.25 1 0 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:11.25,14.3 2 0 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:24.48,25.25 1 0 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:25.25,27.3 1 0 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:37.53,38.28 1 0 -github.com/koss-null/funcfrog/pkg/pipe/functype.go:38.28,40.3 1 0 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:15.46,17.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:20.52,22.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:27.60,29.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:32.53,34.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:38.42,40.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:43.40,45.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:48.30,50.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:53.28,55.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:59.47,61.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:64.28,66.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:69.31,71.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:75.49,77.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:81.38,83.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:86.48,88.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:91.58,93.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipe.go:96.52,98.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:15.53,17.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:20.59,22.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:27.67,29.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:32.32,34.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:37.30,39.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:43.42,45.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:49.41,51.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:55.54,57.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:61.45,63.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:66.55,68.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:71.65,73.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/pipenl.go:76.54,78.2 1 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:13.15,16.33 2 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:16.33,17.42 1 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:17.42,20.5 2 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:21.4,21.20 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:33.20,36.33 2 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:36.33,37.42 1 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:37.42,40.5 2 1 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:41.4,41.20 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:51.98,53.22 2 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:53.22,55.3 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:56.2,57.19 2 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:58.9,59.14 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:60.9,61.29 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:62.10,64.27 2 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:64.27,66.4 1 0 -github.com/koss-null/funcfrog/pkg/pipe/prefixpipe.go:67.3,67.13 1 0 -github.com/koss-null/funcfrog/pkg/pipe/yeet.go:13.38,15.2 1 1 diff --git a/coverage_badge.png b/coverage_badge.png index 648a80e80ebe066c2ae2ee5d6a8815a592c60075..fb42c16a0c1352c859ef5b058a875678c23c63c7 100644 GIT binary patch delta 2515 zcmV;^2`u*O6Ymp{Hh-i^L_t(&f$f=XP*m3$$A5S4y$ibwTwZq(M5t)gj-tklv7#1q zWQdtmqK$wSbr>f)Q&LSv+r%o^$&6-dtf97@F=lKrnW=H2lN!e_j%g+}lgSH{n4l&N zAPDG+yTC3lyUX2sPd^Yh0Rb`jAZh!bxgYM`bAHcr&i~x=a(`EPO(V>ew>ljt+L(arvQ&Sg|XtyU`~B_%9exR8#H4(xV2 zLI}>BIm7w$=kF;{baXT&B_%9auz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pK!o9PMjNHUM*?B^%>-NoHlG6ZRs z$2dCg0={4;k}O5r@2OwUMejY%Lg#YE1}5_-&t6QbM1O901wWj#mY@;f!sYY)C30v` zOaSTGXP+I?P$2}}-Q5I(L7Yw}eSLlO^z=lZSb)C1K5pN>O>%NFE|&{U(@<4)5X&$O zd_EtMNCcTEcOan?3J4r#+?rljzZUa3auw~qNh(fmvlrB4}Vy4I3 zi7kEb)DIvP6%~zW!*}<^#$+124-!IP7{-0qmw%yHCX=b3IbVl!SB7Ck*Wj-cx2mcN zAq3%YnDOJsvt!2&JRZ-8`S&wa=wL(yCbPr?(i*Wu1O#AGhHfJ*TefWUe29ERG7N)^ zj10ozFpZ6kcV1+aVX8JjkNW@6uSyX@xPa6Lw)`)a5Q66BW+X`>CMIUc?bUGij|xfB z4M+tzCWP4XsB?Lgk|e3$y8o~SjTS>Cq+?1r9DYGj6oe3^{Et7WUst2RP#2PP%&vF- Z@;^7SAXnPV?I{2N002ovPDHLkV1leV-uM6j diff --git a/pkg/pipe/pipe_test.go b/pkg/pipe/pipe_test.go index 5a41241..f022886 100644 --- a/pkg/pipe/pipe_test.go +++ b/pkg/pipe/pipe_test.go @@ -1016,6 +1016,69 @@ func TestYetiSnag(t *testing.T) { } } +// prefixpipe + +func TestPrefixMap(t *testing.T) { + res := pipe.Map( + pipe.Slice([]int{1, 2, 3}), + func(x int) string { + return strconv.Itoa(x) + }, + ).Do() + require.Equal(t, []string{"1", "2", "3"}, res) +} + +func TestPrefixMapNL(t *testing.T) { + t.Parallel() + + res := pipe.MapNL( + pipe.Func(func(i int) (int, bool) { + return []int{1, 2, 3}[i], true + }), + func(x int) string { + return strconv.Itoa(x) + }, + ).Take(3).Do() + require.Equal(t, []string{"1", "2", "3"}, res) +} + +func TestPrefixReduce(t *testing.T) { + t.Parallel() + + t.Run("common", func(t *testing.T) { + res := pipe.Reduce( + pipe.Slice([]int{1, 2, 3, 4, 5}), + func(s *string, n *int) string { + return *s + strconv.Itoa(*n) + }, + "the result string is: ", + ) + require.Equal(t, "the result string is: 12345", res) + }) + t.Run("zero_res", func(t *testing.T) { + res := pipe.Reduce( + pipe.Slice([]int{1, 2, 3, 4, 5}). + Filter(func(x *int) bool { return *x > 100 }), + func(s *string, n *int) string { + return *s + strconv.Itoa(*n) + }, + "the result string is: ", + ) + require.Equal(t, "the result string is: ", res) + }) + t.Run("single_res", func(t *testing.T) { + res := pipe.Reduce( + pipe.Slice([]int{1, 2, 3, 4, 5}). + Filter(func(x *int) bool { return *x == 5 }), + func(s *string, n *int) string { + return *s + strconv.Itoa(*n) + }, + "the result string is: ", + ) + require.Equal(t, "the result string is: 5", res) + }) +} + // helping functions func wrap[T any](x T) func() T { diff --git a/pkg/pipies/filters.go b/pkg/pipies/filters.go index 5aa0022..ed79909 100644 --- a/pkg/pipies/filters.go +++ b/pkg/pipies/filters.go @@ -61,9 +61,6 @@ func Distinct[T any, C comparable](getKey func(x *T) C) pipe.Predicate[T] { var mx sync.Mutex return func(y *T) bool { - if y == nil { - return false - } key := getKey(y) mx.Lock() diff --git a/pkg/pipies/pipies_test.go b/pkg/pipies/pipies_test.go index 541f68a..777809f 100644 --- a/pkg/pipies/pipies_test.go +++ b/pkg/pipies/pipies_test.go @@ -116,14 +116,15 @@ func Test_Not(t *testing.T) { func Test_Distinct(t *testing.T) { t.Parallel() - getKey := func(x *int) int { return *x } + z, o, w, r, fv := 0, 1, 2, 3, 5 + getKey := func(x **int) int { return **x } predicate := Distinct(getKey) - filtered := pipe.Slice([]int{1, 2, 3, 3, 2, 2, 1, 5, 2, 3, 1}).Filter(predicate).Do() + filtered := pipe.Slice([]*int{&o, &w, &r, &r, &w, &w, &o, &fv, &w, &r, &z}).Filter(predicate).Do() found := make(map[int]struct{}) for _, f := range filtered { - _, ok := found[f] + _, ok := found[*f] require.False(t, ok, "Distinct element is duplicated") - found[f] = struct{}{} + found[*f] = struct{}{} } }