Skip to content
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

Use %v when formatting objects in assert.Len #1086

Closed
wants to merge 1 commit into from

Conversation

benjaminjkraft
Copy link

Summary

Fix assert.Len's error message for non-%sable values.

Details

It was using %s, which doesn't work if the thing being len'ed is not a
[]string or similar. For example, assert.Len(t, []int{1}, 0) says
that [%!s(int=1)] should have 1 item(s), but has 0. Now it uses %v
which will work for almost anything.

It was using %s, which doesn't work if the thing being len'ed is not a
`[]string` or similar.  For example, `assert.Len(t, []int{1}, 0)` says
that `[%!s(int=1)] should have 1 item(s), but has 0`.  Now it uses `%v`
which will work for almost anything.
Copy link
Contributor

@wwade wwade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and matches the change I was planning to make 😄

@wwade
Copy link
Contributor

wwade commented Nov 29, 2022

@glesica @boyan-soubachov @mvdkleijn could someone please have a look at this one?

@dolmen
Copy link
Collaborator

dolmen commented Oct 31, 2023

@benjaminjkraft @k1ng440 @wwade Could you instead review #1485 which I plan to merge soon?

@dolmen dolmen added bug rejected/duplicate pkg-assert Change related to package testify/assert labels Oct 31, 2023
@dolmen dolmen closed this Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pkg-assert Change related to package testify/assert rejected/duplicate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants