-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert.Same()
for map
#1691
Comments
This is also an issue for me. We have many tests that are verifying cloning of maps, and those tests now fail with this error. This feels like a breaking change. |
After testing things out, it seems like func TestSameMap(t *testing.T) {
a := map[string]string{"z": "z"}
b := map[string]string{"z": "z"}
// succeeds
assert.Equal(t, a, b)
// Both of these succeed
assert.NotSame(t, a, a)
assert.NotSame(t, a, b)
// Both of these fail
assert.Same(t, a, a)
assert.Same(t, a, b)
} Interestingly,
I would hope this function would work with maps though. |
You can use
|
I want to copy a map to ensure that modifying the copied map does not affect the original one. Therefore, I need to verify that the original and the copied maps are not the same, even if Equal() == true. What would be the best way to achieve this? |
Hey @tturbs , you could try the DeepEqual method and check the result:
|
Hello everyone,
I’d like to ask a quick question informally.
118fb83#diff-cfb0727d3ab618e656775b3bb99089481b38a25f8ece2b10913e2d88e492a165R531
I have some concerns regarding this commit. While the changes to the assert.Same() function seem appropriate for pointer comparisons, they are not suitable for comparing maps. In my case, it has become impossible to compare a map with its cloned copy.
If this change is considered appropriate, I believe there should be a separate function specifically for comparing pointer-like objects.
Thanks in advance.
The text was updated successfully, but these errors were encountered: