Skip to content

Commit

Permalink
size_test: add t.Helper annotations
Browse files Browse the repository at this point in the history
This way, error messages will show correct line information.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed May 16, 2022
1 parent 1d23ffa commit 54c3e55
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func BenchmarkParseSize(b *testing.B) {
}

func assertEquals(t *testing.T, expected, actual interface{}) {
t.Helper()
if expected != actual {
t.Errorf("Expected '%v' but got '%v'", expected, actual)
}
Expand All @@ -168,13 +169,15 @@ func (fn parseFn) String() string {
}

func assertSuccessEquals(t *testing.T, expected int64, fn parseFn, arg string) {
t.Helper()
res, err := fn(arg)
if err != nil || res != expected {
t.Errorf("%s(\"%s\") -> expected '%d' but got '%d' with error '%v'", fn, arg, expected, res, err)
}
}

func assertError(t *testing.T, fn parseFn, arg string) {
t.Helper()
res, err := fn(arg)
if err == nil && res != -1 {
t.Errorf("%s(\"%s\") -> expected error but got '%d'", fn, arg, res)
Expand Down

0 comments on commit 54c3e55

Please sign in to comment.