]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cover: fix off-by-one error in TestCoverHTML
authorTobias Klauser <tklauser@distanz.ch>
Tue, 21 Aug 2018 12:27:07 +0000 (14:27 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Wed, 22 Aug 2018 06:54:03 +0000 (06:54 +0000)
Avoid index out of range if len(goldenLines) == len(outLines) + 1

Change-Id: Ic23a85d2b8dd06a615e35a58331e78abe4ad6703
Reviewed-on: https://go-review.googlesource.com/130396
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/cover/cover_test.go

index c818819c3927724081d531058800660c0a2d7f24..8eb7124aad85b69c33195315e897567cb1f94899 100644 (file)
@@ -314,7 +314,7 @@ func TestCoverHTML(t *testing.T) {
        // Compare at the line level, stopping at first different line so
        // we don't generate tons of output if there's an inserted or deleted line.
        for i, goldenLine := range goldenLines {
-               if i > len(outLines) {
+               if i >= len(outLines) {
                        t.Fatalf("output shorter than golden; stops before line %d: %s\n", i+1, goldenLine)
                }
                // Convert all white space to simple spaces, for easy comparison.