...

Source file src/github.com/onsi/gomega/matchers/be_zero_matcher.go

Documentation: github.com/onsi/gomega/matchers

     1  package matchers
     2  
     3  import (
     4  	"reflect"
     5  
     6  	"github.com/onsi/gomega/format"
     7  )
     8  
     9  type BeZeroMatcher struct {
    10  }
    11  
    12  func (matcher *BeZeroMatcher) Match(actual interface{}) (success bool, err error) {
    13  	if actual == nil {
    14  		return true, nil
    15  	}
    16  	zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface()
    17  
    18  	return reflect.DeepEqual(zeroValue, actual), nil
    19  
    20  }
    21  
    22  func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) {
    23  	return format.Message(actual, "to be zero-valued")
    24  }
    25  
    26  func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
    27  	return format.Message(actual, "not to be zero-valued")
    28  }
    29  

View as plain text