Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame] | 1 | package matchers |
| 2 | |
| 3 | import ( |
| 4 | "github.com/onsi/gomega/internal/oraclematcher" |
| 5 | "github.com/onsi/gomega/types" |
| 6 | ) |
| 7 | |
| 8 | type NotMatcher struct { |
| 9 | Matcher types.GomegaMatcher |
| 10 | } |
| 11 | |
| 12 | func (m *NotMatcher) Match(actual interface{}) (bool, error) { |
| 13 | success, err := m.Matcher.Match(actual) |
| 14 | if err != nil { |
| 15 | return false, err |
| 16 | } |
| 17 | return !success, nil |
| 18 | } |
| 19 | |
| 20 | func (m *NotMatcher) FailureMessage(actual interface{}) (message string) { |
| 21 | return m.Matcher.NegatedFailureMessage(actual) // works beautifully |
| 22 | } |
| 23 | |
| 24 | func (m *NotMatcher) NegatedFailureMessage(actual interface{}) (message string) { |
| 25 | return m.Matcher.FailureMessage(actual) // works beautifully |
| 26 | } |
| 27 | |
| 28 | func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { |
| 29 | return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value |
| 30 | } |