forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStrSliceConstruct(t *testing.T) {
|
||||
type args struct {
|
||||
length int
|
||||
filter StrSliceConstructFilter
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "1",
|
||||
args: args{
|
||||
length: 5,
|
||||
filter: func(index int) (string, bool) {
|
||||
return fmt.Sprintf("%d", index), true
|
||||
},
|
||||
},
|
||||
want: []string{"0", "1", "2", "3", "4"},
|
||||
},
|
||||
{
|
||||
name: "2",
|
||||
args: args{
|
||||
length: 5,
|
||||
filter: func(index int) (string, bool) {
|
||||
return fmt.Sprintf("%d", index*index), true
|
||||
},
|
||||
},
|
||||
want: []string{"0", "1", "4", "9", "16"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := StrSliceConstruct(tt.args.length, tt.args.filter); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("StrSliceConstruct() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user