Skip to content

Commit

Permalink
fix: add missing calls to t.Helper() (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
halimath authored Mar 2, 2024
1 parent c2f1408 commit a08cfac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions is/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func Error(got, target error) expect.Expectation {
// NoError expects v to be nil.
func NoError(v error) expect.Expectation {
return expect.ExpectFunc(func(t expect.TB) {
t.Helper()

if v != nil {
t.Errorf("expected no error but got %q", v)
}
Expand Down
2 changes: 2 additions & 0 deletions is/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func MapContaining[T ~map[K]V, K, V comparable](got T, key K, val V) expect.Expe
// MapOfLen expects got to contain want elements.
func MapOfLen[T ~map[K]V, K comparable, V any](got T, want int) expect.Expectation {
return expect.ExpectFunc(func(t expect.TB) {
t.Helper()

gotLen := len(got)
if gotLen != want {
t.Errorf("expected %v to have len %d but got %d", got, want, gotLen)
Expand Down
2 changes: 2 additions & 0 deletions is/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
// StringOfLen expects got to have byte length want.
func StringOfLen(got string, want int) expect.Expectation {
return expect.ExpectFunc(func(t expect.TB) {
t.Helper()

gotLen := len(got)
if gotLen != want {
t.Errorf("expected %q to have len %d but got %d", got, want, gotLen)
Expand Down

0 comments on commit a08cfac

Please sign in to comment.