2018-01-29 19:44:18 +00:00
|
|
|
package gstruct_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
. "github.com/onsi/gomega/gstruct"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("PointTo", func() {
|
|
|
|
It("should fail when passed nil", func() {
|
|
|
|
var p *struct{}
|
2018-09-05 15:36:14 +00:00
|
|
|
Expect(p).Should(BeNil())
|
2018-01-29 19:44:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should succeed when passed non-nil pointer", func() {
|
|
|
|
var s struct{}
|
2018-09-05 15:36:14 +00:00
|
|
|
Expect(&s).Should(PointTo(Ignore()))
|
2018-01-29 19:44:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should unwrap the pointee value", func() {
|
|
|
|
i := 1
|
2018-09-05 15:36:14 +00:00
|
|
|
Expect(&i).Should(PointTo(Equal(1)))
|
|
|
|
Expect(&i).ShouldNot(PointTo(Equal(2)))
|
2018-01-29 19:44:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should work with nested pointers", func() {
|
|
|
|
i := 1
|
|
|
|
ip := &i
|
|
|
|
ipp := &ip
|
2018-09-05 15:36:14 +00:00
|
|
|
Expect(ipp).Should(PointTo(PointTo(Equal(1))))
|
|
|
|
Expect(ipp).ShouldNot(PointTo(PointTo(Equal(2))))
|
2018-01-29 19:44:18 +00:00
|
|
|
})
|
|
|
|
})
|