Skip to content

Commit

Permalink
strings: add a test case of growLen is negative
Browse files Browse the repository at this point in the history
Before committing,  the test coverage of strings/builder.go is 97.4%
After committing,  the test coverage of strings/builder.go is 100%

Change-Id: I22643b1c4632b5ca7ef98362f32bb85faae80bad
GitHub-Last-Rev: 2a55ca3e33d3aabd2ccc047de580abcfe05d6bb4
GitHub-Pull-Request: golang/go#55004
Reviewed-on: https://go-review.googlesource.com/c/go/+/430156
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Jenny Rakoczy <[email protected]>
  • Loading branch information
cuishuang authored and gopherbot committed Sep 13, 2022
1 parent 77420fa commit 09f3ff1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/strings/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ func TestBuilderGrow(t *testing.T) {
t.Errorf("growLen=%d: got %d allocs during Write; want %v", growLen, g, w)
}
}
// when growLen < 0, should panic
var a Builder
n := -1
defer func() {
if r := recover(); r == nil {
t.Errorf("a.Grow(%d) should panic()", n)
}
}()
a.Grow(n)
}

func TestBuilderWrite2(t *testing.T) {
Expand Down

0 comments on commit 09f3ff1

Please sign in to comment.