You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
807 B

  1. package matchers
  2. import (
  3. "github.com/onsi/gomega/internal/oraclematcher"
  4. "github.com/onsi/gomega/types"
  5. )
  6. type NotMatcher struct {
  7. Matcher types.GomegaMatcher
  8. }
  9. func (m *NotMatcher) Match(actual interface{}) (bool, error) {
  10. success, err := m.Matcher.Match(actual)
  11. if err != nil {
  12. return false, err
  13. }
  14. return !success, nil
  15. }
  16. func (m *NotMatcher) FailureMessage(actual interface{}) (message string) {
  17. return m.Matcher.NegatedFailureMessage(actual) // works beautifully
  18. }
  19. func (m *NotMatcher) NegatedFailureMessage(actual interface{}) (message string) {
  20. return m.Matcher.FailureMessage(actual) // works beautifully
  21. }
  22. func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
  23. return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
  24. }