Files
go-easy-utils/sliceUtil/is_slice_test.go
jeffery 9a8c60b30a Feature/generic type (#19)
Supports generics and any
2023-04-07 19:21:05 +08:00

25 lines
446 B
Go

package sliceUtil
import "testing"
func TestIsSlice(t *testing.T) {
var tests = []struct {
input any
want bool
}{
{[]int{1, 1, 3}, true},
{[]any{1, 2, "a"}, true},
{[]map[string]any{
{"1": 1},
{"c": 89},
}, true},
{"1234", false},
{make(chan int), false},
}
for _, test := range tests {
if got := IsSlice(test.input); got != test.want {
t.Errorf("IsSlice(%v) = %v; want %v", test.input, got, test.want)
}
}
}