github.com/onsi/gomega@v1.32.0/gstruct/pointer_test.go (about) 1 package gstruct_test 2 3 import ( 4 . "github.com/onsi/ginkgo/v2" 5 . "github.com/onsi/gomega" 6 . "github.com/onsi/gomega/gstruct" 7 ) 8 9 var _ = Describe("PointTo", func() { 10 It("should fail when passed nil", func() { 11 var p *struct{} 12 Expect(p).Should(BeNil()) 13 }) 14 15 It("should succeed when passed non-nil pointer", func() { 16 var s struct{} 17 Expect(&s).Should(PointTo(Ignore())) 18 }) 19 20 It("should unwrap the pointee value", func() { 21 i := 1 22 Expect(&i).Should(PointTo(Equal(1))) 23 Expect(&i).ShouldNot(PointTo(Equal(2))) 24 }) 25 26 It("should work with nested pointers", func() { 27 i := 1 28 ip := &i 29 ipp := &ip 30 Expect(ipp).Should(PointTo(PointTo(Equal(1)))) 31 Expect(ipp).ShouldNot(PointTo(PointTo(Equal(2)))) 32 }) 33 })