stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
23.26k stars 1.59k forks source link

`NotSame` should fail if args are not pointers #1661

Open brackendawson opened 4 hours ago

brackendawson commented 4 hours ago

Discussed in https://github.com/stretchr/testify/discussions/1660

Originally posted by **n4nn31355** October 16, 2024 It's confusing and error-prone that `NotSame` checks nothing if any of the values is not a pointer. Is there a reason for this, or may we consider it a bug that needs an issue? ``` a := struct{ byte }{} require.NotSame(t, a, a) // Doesn't fail require.NotSame(t, &a, &a) // Fails ```
brackendawson commented 4 hours ago

This is a simple bug, the signature of samePointers needs to be changed to:

func samePointers(first, second interface{}) (same bool, ok bool)