Skip to content

assert.Len: print value last - #732

Closed
christopinka wants to merge 3 commits into
stretchr:masterfrom
christopinka:christopinka-assert-len-patch-1
Closed

christopinka wants to merge 3 commits into
stretchr:masterfrom
christopinka:christopinka-assert-len-patch-1

Conversation

@christopinka

@christopinka christopinka commented Feb 22, 2019

Copy link
Copy Markdown

#207 (comment) - Adjust assert.Len() fail message making the object last so that large object output doesn't obscure the length difference.

[stretchr#207 (comment)] - Adjust assert.Len() fail message making the object last so that large object output doesn't obscure the length difference.
Comment thread assert/assertions.go
ok, l := getLen(object)
if !ok {
//TODO: should it be - \"%s\" could not be applied <to> builtin len() or maybe "len() could not be applied to \"%s\"
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Isn't it - the application of the function ƒ to its argument x? len() applied to object? There could be something I'm missing...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, I think it should say: "Could not apply len() to "%s"".

@viktorasm

Copy link
Copy Markdown

This would be a very welcome change - having difference at the end of message makes it hard to read

@dolmen dolmen added pkg-assert Change related to package testify/assert must-rebase labels Jul 31, 2023

@dolmen dolmen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Must be rebased on master.

@dolmen dolmen added enhancement: output format Enhancement related to formatting of messages assert.Len labels May 30, 2025
@dolmen dolmen changed the title Adjust assert.Len() fail message assert.Len: print value last May 30, 2025
@brackendawson

Copy link
Copy Markdown
Collaborator

Related to #1801

@dolmen

dolmen commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Has #1646 (truncate long messages) solved the readability issue in another way?

At least length is nowadays displayed last, as requested.

@dolmen dolmen closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assert.Len enhancement: output format Enhancement related to formatting of messages must-rebase pkg-assert Change related to package testify/assert

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants