Skip to content

Commit

Permalink
empty: add type conversions cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom committed Nov 17, 2024
1 parent e19e926 commit 39cb0f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
14 changes: 8 additions & 6 deletions analyzer/testdata/src/checkers-default/empty/empty_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ func TestEmptyChecker_LenVarIndependence(t *testing.T) {
ch chan int
)

assert.Empty(t, arr) // want "empty: use assert\\.Empty"
assert.Empty(t, arrPtr) // want "empty: use assert\\.Empty"
assert.Empty(t, sl) // want "empty: use assert\\.Empty"
assert.Empty(t, mp) // want "empty: use assert\\.Empty"
assert.Empty(t, str) // want "empty: use assert\\.Empty"
assert.Empty(t, ch) // want "empty: use assert\\.Empty"
assert.Empty(t, arr) // want "empty: use assert\\.Empty"
assert.Empty(t, arrPtr) // want "empty: use assert\\.Empty"
assert.Empty(t, sl) // want "empty: use assert\\.Empty"
assert.Empty(t, mp) // want "empty: use assert\\.Empty"
assert.Empty(t, str) // want "empty: use assert\\.Empty"
assert.Empty(t, []byte(str)) // want "empty: use assert\\.Empty"
assert.Empty(t, string(str)) // want "empty: use assert\\.Empty"
assert.Empty(t, ch) // want "empty: use assert\\.Empty"
}

func TestEmptyChecker_Ignored(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/testgen/gen_empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (g EmptyTestsGenerator) TemplateData() any {
}{
CheckerName: CheckerName(checker),
LenTest: lenTest{
Vars: []string{"arr", "arrPtr", "sl", "mp", "str", "ch"},
Vars: []string{"arr", "arrPtr", "sl", "mp", "str", "[]byte(str)", "string(str)", "ch"},
Assrn: Assertion{Fn: "Equal", Argsf: "0, len(%s)", ReportMsgf: report, ProposedFn: "Empty", ProposedArgsf: "%s"},
},
Tests: []test{
Expand Down

0 comments on commit 39cb0f6

Please sign in to comment.