7 "github.com/onsi/gomega/format"
10 type EqualMatcher struct {
14 func (matcher *EqualMatcher) Match(actual interface{}) (success bool, err 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.")
18 return reflect.DeepEqual(actual, matcher.Expected), nil
21 func (matcher *EqualMatcher) FailureMessage(actual interface{}) (message string) {
22 actualString, actualOK := actual.(string)
23 expectedString, expectedOK := matcher.Expected.(string)
24 if actualOK && expectedOK {
25 return format.MessageWithDiff(actualString, "to equal", expectedString)
28 return format.Message(actual, "to equal", matcher.Expected)
31 func (matcher *EqualMatcher) NegatedFailureMessage(actual interface{}) (message string) {
32 return format.Message(actual, "not to equal", matcher.Expected)