franela / goblin

Minimal and Beautiful Go testing framework
MIT License
884 stars 79 forks source link

Added IsNil and IsNotNil assertions #49

Open lukaszb opened 8 years ago

marcosnils commented 8 years ago

@lukaszb thanks for the contribution. I like the idea of adding these type of assertions but we need to make sure to catch nil structs as well. I.E:

var nilStruct struct{}
g.It("IsNil should trigger", func() {
    g.Assert(nilStruct).IsNil()
})

Currently this fails, It'd be nice if we could catch these scenarios also.

lukaszb commented 8 years ago

@marcosnils sure, can do that. btw, can you look at travis failed build? It seems to fail for code I haven't actually touched.

ammario commented 8 years ago
var nilStruct struct{}

This struct is zeroed, not nil (only pointers can be nil) so the behavior could be misleading.

IsZero() / IsNotZero() are probably better names for this more flexible functionality.