Closed ghost closed 4 years ago
As per title. Example:
func TestWeirdness(t *testing.T) { test := Goblin(t) test.Describe("Pointer Weirdness", func() { test.It("Should PASS but FAILS", func() { var ptr *[]int test.Assert(ptr).IsNil() }) test.It("Should PASS but FAILS", func() { var ptr *[2]int test.Assert(ptr).IsNil() }) test.It("Should PASS but FAILS", func() { var ptr *time.Time test.Assert(ptr).IsNil() }) test.It("Should FAIL but PASSES", func() { var ptr *[]int test.Assert(ptr).IsNotNil() }) test.It("Should FAIL but PASSES", func() { var ptr *[2]int test.Assert(ptr).IsNotNil() }) test.It("Should FAIL but PASSES", func() { var ptr *time.Time test.Assert(ptr).IsNotNil() }) }) }
Behavior is as expected since this is how Golang nil works with nil pointers and interfaces. Check https://blog.golang.org/laws-of-reflection
As per title. Example: