stretchr / testify

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

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

Closed brackendawson closed 4 weeks ago

brackendawson commented 1 month 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 1 month ago

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

func samePointers(first, second interface{}) (same bool, ok bool)
sikehish commented 1 month ago

I'd love to take this up. Could you assign this to me?

sikehish commented 1 month ago

I'd love to take this up. Could you assign this to me?

Thank you. Im looking into the issue.

sikehish commented 1 month ago

Hi @brackendawson , I've raised a PR #1664 , do let me know if any changes need to be made.