1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:54:49 -07:00

strings: add a test case of growLen is negative

Signed-off-by: cui fliter <imcusg@gmail.com>
This commit is contained in:
cui fliter 2022-09-11 20:36:07 +08:00
parent 54182ff54a
commit 2a55ca3e33

View File

@ -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) {