From a8a7e73600403da6e70973e7a8833370bd1d9174 Mon Sep 17 00:00:00 2001 From: xing Date: Sat, 24 Sep 2022 22:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/func_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/helper/func_test.go b/helper/func_test.go index ea211f6..c5f66a1 100644 --- a/helper/func_test.go +++ b/helper/func_test.go @@ -381,3 +381,33 @@ func TestSliceFilter(t *testing.T) { }) } } + +func TestSliceMap(t *testing.T) { + type args struct { + arr []int8 + fn func(int8) int + } + tests := []struct { + name string + args args + want []int + }{ + { + name: "t1", + args: args{ + arr: RangeSlice[int8](1, 10, 1), + fn: func(i int8) int { + return int(i) + }, + }, + want: RangeSlice(1, 10, 1), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := SliceMap(tt.args.arr, tt.args.fn); !reflect.DeepEqual(got, tt.want) { + t.Errorf("SliceMap() = %v, want %v", got, tt.want) + } + }) + } +}