aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go
blob: b39c9144be7d75eae3c975a0d39a1379408af286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package matchers

import (
	"github.com/onsi/gomega/format"
	"reflect"
)

type BeZeroMatcher struct {
}

func (matcher *BeZeroMatcher) Match(actual interface{}) (success bool, err error) {
	if actual == nil {
		return true, nil
	}
	zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface()

	return reflect.DeepEqual(zeroValue, actual), nil

}

func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "to be zero-valued")
}

func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
	return format.Message(actual, "not to be zero-valued")
}