Skip to content

Added IsNil and IsNotNil assertions#49

Open
lukaszb wants to merge 1 commit into
franela:masterfrom
lukaszb:nil-assertions
Open

Added IsNil and IsNotNil assertions#49
lukaszb wants to merge 1 commit into
franela:masterfrom
lukaszb:nil-assertions

Conversation

@lukaszb

@lukaszb lukaszb commented Jan 21, 2016

Copy link
Copy Markdown

No description provided.

@marcosnils

Copy link
Copy Markdown
Member

@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

lukaszb commented Jan 21, 2016

Copy link
Copy Markdown
Author

@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

ammario commented Sep 16, 2016

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants