...

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

Documentation: github.com/onsi/gomega/matchers

     1  // untested sections: 2
     2  
     3  package matchers
     4  
     5  import (
     6  	"fmt"
     7  
     8  	"github.com/onsi/gomega/format"
     9  )
    10  
    11  type BeEmptyMatcher struct {
    12  }
    13  
    14  func (matcher *BeEmptyMatcher) Match(actual interface{}) (success bool, err error) {
    15  	length, ok := lengthOf(actual)
    16  	if !ok {
    17  		return false, fmt.Errorf("BeEmpty matcher expects a string/array/map/channel/slice.  Got:\n%s", format.Object(actual, 1))
    18  	}
    19  
    20  	return length == 0, nil
    21  }
    22  
    23  func (matcher *BeEmptyMatcher) FailureMessage(actual interface{}) (message string) {
    24  	return format.Message(actual, "to be empty")
    25  }
    26  
    27  func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
    28  	return format.Message(actual, "not to be empty")
    29  }
    30  

View as plain text