MCPcopy Create free account
hub / github.com/microsoft/go-winio / Test_BufferCapacity

Function Test_BufferCapacity

internal/stringbuffer/wstring_test.go:7–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5import "testing"
6
7func Test_BufferCapacity(t *testing.T) {
8 b := NewWString()
9
10 c := b.Cap()
11 if c < MinWStringCap {
12 t.Fatalf("expected capacity >= %d, got %d", MinWStringCap, c)
13 }
14
15 if l := len(b.b); l != int(c) {
16 t.Fatalf("buffer length (%d) and capacity (%d) mismatch", l, c)
17 }
18
19 n := uint32(1.5 * MinWStringCap)
20 nn := b.ResizeTo(n)
21 if len(b.b) != int(nn) {
22 t.Fatalf("resized buffer should be %d, was %d", nn, len(b.b))
23 }
24 if n > nn {
25 t.Fatalf("resized to a value smaller than requested")
26 }
27}
28
29func Test_BufferFree(t *testing.T) {
30 // make sure free-ing doesn't set pooled buffer to nil as well

Callers

nothing calls this directly

Calls 3

CapMethod · 0.95
ResizeToMethod · 0.95
NewWStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…