summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/gstruct/pointer.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-06-24 11:29:13 +0200
committerValentin Rothberg <rothberg@redhat.com>2019-06-24 13:20:59 +0200
commitd697456dc90adbaf68224ed7c115b38d5855e582 (patch)
tree5fd88c48b34e7bead0028fa97e39f43f03880642 /vendor/github.com/onsi/gomega/gstruct/pointer.go
parenta3211b73c62a9fcc13f09305bf629ef507b26d34 (diff)
downloadpodman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.gz
podman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.bz2
podman-d697456dc90adbaf68224ed7c115b38d5855e582.zip
migrate to go-modules
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/onsi/gomega/gstruct/pointer.go')
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/pointer.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/github.com/onsi/gomega/gstruct/pointer.go b/vendor/github.com/onsi/gomega/gstruct/pointer.go
deleted file mode 100644
index 0a2f35de3..000000000
--- a/vendor/github.com/onsi/gomega/gstruct/pointer.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package gstruct
-
-import (
- "fmt"
- "reflect"
-
- "github.com/onsi/gomega/format"
- "github.com/onsi/gomega/types"
-)
-
-//PointTo applies the given matcher to the value pointed to by actual. It fails if the pointer is
-//nil.
-// actual := 5
-// Expect(&actual).To(PointTo(Equal(5)))
-func PointTo(matcher types.GomegaMatcher) types.GomegaMatcher {
- return &PointerMatcher{
- Matcher: matcher,
- }
-}
-
-type PointerMatcher struct {
- Matcher types.GomegaMatcher
-
- // Failure message.
- failure string
-}
-
-func (m *PointerMatcher) Match(actual interface{}) (bool, error) {
- val := reflect.ValueOf(actual)
-
- // return error if actual type is not a pointer
- if val.Kind() != reflect.Ptr {
- return false, fmt.Errorf("PointerMatcher expects a pointer but we have '%s'", val.Kind())
- }
-
- if !val.IsValid() || val.IsNil() {
- m.failure = format.Message(actual, "not to be <nil>")
- return false, nil
- }
-
- // Forward the value.
- elem := val.Elem().Interface()
- match, err := m.Matcher.Match(elem)
- if !match {
- m.failure = m.Matcher.FailureMessage(elem)
- }
- return match, err
-}
-
-func (m *PointerMatcher) FailureMessage(_ interface{}) (message string) {
- return m.failure
-}
-
-func (m *PointerMatcher) NegatedFailureMessage(actual interface{}) (message string) {
- return m.Matcher.NegatedFailureMessage(actual)
-}