arnaucube
arnaucube/mirror-to-giteaPublic Self-hosted repository
mirror-to-gitea/vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go
vendor/github.com/onsi/gomega/matchers/be_empty_matcher.goRaw
 1// untested sections: 2
 2
 3package matchers
 4
 5import (
 6	"fmt"
 7
 8	"github.com/onsi/gomega/format"
 9)
10
11type BeEmptyMatcher struct {
12}
13
14func (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
23func (matcher *BeEmptyMatcher) FailureMessage(actual interface{}) (message string) {
24	return format.Message(actual, "to be empty")
25}
26
27func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
28	return format.Message(actual, "not to be empty")
29}