Same asserts that two pointers reference the same object. assert.Same(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{})
| 498 | // Both arguments must be pointer variables. Pointer variable sameness is |
| 499 | // determined based on the equality of both type and value. |
| 500 | func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { |
| 501 | if h, ok := t.(tHelper); ok { |
| 502 | h.Helper() |
| 503 | } |
| 504 | |
| 505 | same, ok := samePointers(expected, actual) |
| 506 | if !ok { |
| 507 | return Fail(t, "Both arguments must be pointers", msgAndArgs...) |
| 508 | } |
| 509 | |
| 510 | if !same { |
| 511 | // both are pointers but not the same type & pointing to the same address |
| 512 | return Fail(t, fmt.Sprintf("Not same: \n"+ |
| 513 | "expected: %p %#v\n"+ |
| 514 | "actual : %p %#v", expected, expected, actual, actual), msgAndArgs...) |
| 515 | } |
| 516 | |
| 517 | return true |
| 518 | } |
| 519 | |
| 520 | // NotSame asserts that two pointers do not reference the same object. |
| 521 | // |