Skip to content

Commit

Permalink
Add extra test for LineCounter & update msg
Browse files Browse the repository at this point in the history
  • Loading branch information
LoyalPotato committed Dec 22, 2023
1 parent 2159be6 commit 425bc68
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/internal/test/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,23 @@ func TestLineCounter(t *testing.T) {
}

if lines != 0 {
t.Fatalf(`LineCounter with reader for %q didn't return 0 lines`, s)
t.Fatalf(`LineCounter with reader for %q didn't return 0 lines. Returned instead %d`, s, lines)
}
})

t.Run("string has 2 lines", func(t *testing.T) {
s := `line one
line two
`
sReader := strings.NewReader(s)
lines, err := utils.LineCounter(sReader)
want := 2
if err != nil {
t.Fatalf(`LineCounter error occurred: %v`, err)
}

if lines != want {
t.Fatalf(`LineCounter with reader for %q didn't return %d lines. Returned instead %d`, s, want, lines)
}
})
}

0 comments on commit 425bc68

Please sign in to comment.