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

Function NotSame

assert/assertions.go:561–578  ·  view source on GitHub ↗

NotSame asserts that two pointers do not reference the same object. assert.NotSame(t, ptr1, ptr2) Both arguments must be pointer variables. Pointer variable sameness is determined based on the equality of both type and value.

(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

559// Both arguments must be pointer variables. Pointer variable sameness is
560// determined based on the equality of both type and value.
561func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
562 if h, ok := t.(tHelper); ok {
563 h.Helper()
564 }
565
566 same, ok := samePointers(expected, actual)
567 if !ok {
568 // fails when the arguments are not pointers
569 return !(Fail(t, "Both arguments must be pointers", msgAndArgs...))
570 }
571
572 if same {
573 return Fail(t, fmt.Sprintf(
574 "Expected and actual point to the same object: %p %#[1]v",
575 expected), msgAndArgs...)
576 }
577 return true
578}
579
580// samePointers checks if two generic interface objects are pointers of the same
581// type pointing to the same object. It returns two values: same indicating if

Callers 4

NotSameFunction · 0.92
NotSamefFunction · 0.70
TestNotSameFunction · 0.70
NotSameMethod · 0.70

Calls 3

samePointersFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65

Tested by 1

TestNotSameFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…