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

len: support len-len and value-len cases #204

Merged
merged 8 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
len: add disclaimer about not-len-first assetions
  • Loading branch information
Antonboom committed Nov 16, 2024
commit 1d666af3dc3c74c17999df6bbdee40a38fba2064
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ assert.Len(t, arr, len(expArr))
**Enabled by default**: true. <br>
**Reason**: More appropriate `testify` API with clearer failure message.

> [!CAUTION]
> The checker ignores assertions in which length checking is not a priority, e.g.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a link to the issue where the reason are provided could help people to understand it's normal, and it would be a bad thing to change

Copy link
Contributor

Choose a reason for hiding this comment

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

This link would be the best I think

#167 (comment)

> ```go
> assert.Equal(t, len(arr), value)
> ```

---

### negative-positive
Expand Down
4 changes: 4 additions & 0 deletions internal/checkers/len.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import (
// assert.Len(t, arr, 42)
// assert.Len(t, arr, value)
// assert.Len(t, arr, len(expArr))
//
// The checker ignores assertions in which length checking is not a priority, e.g
//
// assert.Equal(t, len(arr), value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the link here too

Copy link
Contributor

Choose a reason for hiding this comment

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

I would add it in the code, but I'm unsure about the exact line

type Len struct{}

// NewLen constructs Len checker.
Expand Down