-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useless-assert: add NotElementsMatch and NotErrorAs (#220)
* Upgrade testdata to v1.10.0 of testify * self-review fixes * issue 213 debug * useless-assert: add NotElementsMatch and NotErrorAs
- Loading branch information
Showing
4 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
analyzer/testdata/src/checkers-default/useless-assert/useless_assert_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package debug | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestErrorAsGenericTarget(t *testing.T) { | ||
var err error = new(os.PathError) | ||
|
||
errorAs[*os.PathError]()(t, err) | ||
errorAs[*os.LinkError]()(t, err) | ||
} | ||
|
||
func errorAs[T error]() require.ErrorAssertionFunc { | ||
return func(t require.TestingT, err error, msgAndArgs ...interface{}) { | ||
var target T | ||
require.ErrorAs(t, err, &target, msgAndArgs...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters