MCPcopy
hub / github.com/stretchr/testify / NotImplements

Function NotImplements

assert/assertions.go:442–456  ·  view source on GitHub ↗

NotImplements asserts that an object does not implement the specified interface. assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))

(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

440//
441// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
442func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
443 if h, ok := t.(tHelper); ok {
444 h.Helper()
445 }
446 interfaceType := reflect.TypeOf(interfaceObject).Elem()
447
448 if object == nil {
449 return Fail(t, fmt.Sprintf("Cannot check if nil does not implement %v", interfaceType), msgAndArgs...)
450 }
451 if reflect.TypeOf(object).Implements(interfaceType) {
452 return Fail(t, fmt.Sprintf("%T implements %v", object, interfaceType), msgAndArgs...)
453 }
454
455 return true
456}
457
458func isType(expectedType, object interface{}) bool {
459 return ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType))

Callers 4

NotImplementsFunction · 0.92
NotImplementsfFunction · 0.70
TestNotImplementsFunction · 0.70
NotImplementsMethod · 0.70

Calls 3

FailFunction · 0.70
HelperMethod · 0.65
ImplementsMethod · 0.45

Tested by 1

TestNotImplementsFunction · 0.56