Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom committed Oct 6, 2024
1 parent 7fa49a5 commit 4dc9ef1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/analyzer/testdata/src/opposite-chan-map-only/positive.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ func anyType() (any, error) {
func m1() (map[int]int, error) {
return make(map[int]int), io.EOF // want "return both a non-nil error and a valid value: use separate returns instead"
}

func structPtrInvalid() (*int, error) {
return nil, nil
}

func structPtrValid() (*int, error) {
return new(int), nil
}

func chInvalid() (chan int, error) {
return nil, nil // want "return both a `nil` error and an invalid value: use a sentinel error instead"
}
8 changes: 8 additions & 0 deletions pkg/analyzer/testdata/src/opposite/opposite.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ type (
)

func wrap(err error) error { return err }

func structPtr() (*int, error) {
return nil, nil // want "return both a `nil` error and an invalid value: use a sentinel error instead"
}

func structPtrValid() (*int, error) {
return new(int), nil
}

0 comments on commit 4dc9ef1

Please sign in to comment.