mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
strings: add a test case of growLen is negative
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: 2a55ca3e33
GitHub-Pull-Request: golang/go#55004
Reviewed-on: https://go-review.googlesource.com/c/go/+/430156
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
This commit is contained in:
parent
77420fa119
commit
09f3ff174c
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user