github.com/MontFerret/ferret@v0.18.0/pkg/runtime/core/helpers_test.go (about) 1 package core_test 2 3 import ( 4 "testing" 5 "unsafe" 6 7 . "github.com/smartystreets/goconvey/convey" 8 9 "github.com/MontFerret/ferret/pkg/runtime/core" 10 ) 11 12 type DummyStruct struct{} 13 14 func TestIsNil(t *testing.T) { 15 Convey("Should match", t, func() { 16 // nil == invalid 17 t := core.IsNil(nil) 18 19 So(t, ShouldBeTrue) 20 21 a := []string{} 22 t = core.IsNil(a) 23 24 So(t, ShouldBeFalse) 25 26 b := make([]string, 1) 27 t = core.IsNil(b) 28 29 So(t, ShouldBeFalse) 30 31 c := make(map[string]string) 32 t = core.IsNil(c) 33 34 So(t, ShouldBeFalse) 35 36 var s struct { 37 Test string 38 } 39 t = core.IsNil(s) 40 41 So(t, ShouldBeFalse) 42 43 f := func() {} 44 t = core.IsNil(f) 45 46 So(t, ShouldBeFalse) 47 48 i := DummyStruct{} 49 t = core.IsNil(i) 50 51 So(t, ShouldBeFalse) 52 53 ch := make(chan string) 54 t = core.IsNil(ch) 55 56 So(t, ShouldBeFalse) 57 58 var y unsafe.Pointer 59 var vy int 60 y = unsafe.Pointer(&vy) 61 t = core.IsNil(y) 62 63 So(t, ShouldBeFalse) 64 }) 65 }