7 "github.com/onsi/gomega/format"
10 type AssignableToTypeOfMatcher struct {
14 func (matcher *AssignableToTypeOfMatcher) Match(actual interface{}) (success bool, err error) {
15 if actual == nil || matcher.Expected == nil {
16 return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
19 actualType := reflect.TypeOf(actual)
20 expectedType := reflect.TypeOf(matcher.Expected)
22 return actualType.AssignableTo(expectedType), nil
25 func (matcher *AssignableToTypeOfMatcher) FailureMessage(actual interface{}) string {
26 return format.Message(actual, fmt.Sprintf("to be assignable to the type: %T", matcher.Expected))
29 func (matcher *AssignableToTypeOfMatcher) NegatedFailureMessage(actual interface{}) string {
30 return format.Message(actual, fmt.Sprintf("not to be assignable to the type: %T", matcher.Expected))