You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
544 B
33 lines
544 B
5 years ago
|
package utils
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestIsNil(t *testing.T) {
|
||
|
|
||
|
testvalues := []struct {
|
||
|
i interface{}
|
||
|
isnil bool
|
||
|
}{
|
||
|
{nil, true},
|
||
|
{(*string)(nil), true},
|
||
|
{([]string)(nil), true},
|
||
|
{(map[string]string)(nil), true},
|
||
|
{(func() bool)(nil), true},
|
||
|
{(chan func() bool)(nil), true},
|
||
|
{"", true},
|
||
|
{0, true},
|
||
|
{append(([]string)(nil), ""), false},
|
||
|
{[]string{}, false},
|
||
|
{1, false},
|
||
|
{"1", false},
|
||
|
}
|
||
|
|
||
|
for _, tt := range testvalues {
|
||
|
assert.Equal(t, tt.isnil, IsNil(tt.i))
|
||
|
}
|
||
|
}
|