mirror-to-gitea/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go
vendor/github.com/onsi/gomega/matchers/be_zero_matcher.goRaw
1package matchers
2
3import (
4 "reflect"
5
6 "github.com/onsi/gomega/format"
7)
8
9type BeZeroMatcher struct {
10}
11
12func (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
22func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) {
23 return format.Message(actual, "to be zero-valued")
24}
25
26func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
27 return format.Message(actual, "not to be zero-valued")
28}