initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / be_identical_to.go
1 package matchers
2
3 import (
4         "fmt"
5         "runtime"
6
7         "github.com/onsi/gomega/format"
8 )
9
10 type BeIdenticalToMatcher struct {
11         Expected interface{}
12 }
13
14 func (matcher *BeIdenticalToMatcher) Match(actual interface{}) (success bool, matchErr error) {
15         if actual == nil && matcher.Expected == nil {
16                 return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead.  This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
17         }
18
19         defer func() {
20                 if r := recover(); r != nil {
21                         if _, ok := r.(runtime.Error); ok {
22                                 success = false
23                                 matchErr = nil
24                         }
25                 }
26         }()
27
28         return actual == matcher.Expected, nil
29 }
30
31 func (matcher *BeIdenticalToMatcher) FailureMessage(actual interface{}) string {
32         return format.Message(actual, "to be identical to", matcher.Expected)
33 }
34
35 func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual interface{}) string {
36         return format.Message(actual, "not to be identical to", matcher.Expected)
37 }