MCPcopy Create free account
hub / github.com/cloudwego/netpoll / TestLinkBufferGetBytes

Function TestLinkBufferGetBytes

nocopy_linkbuffer_test.go:91–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestLinkBufferGetBytes(t *testing.T) {
92 buf := NewLinkBuffer()
93 var (
94 num = 10
95 b = 1
96 expectedLen = 0
97 )
98 for i := 0; i < num; i++ {
99 expectedLen += b
100 n, err := buf.WriteBinary(make([]byte, b))
101 MustNil(t, err)
102 Equal(t, n, b)
103 b *= 10
104 }
105 buf.Flush()
106 Equal(t, int(buf.length), expectedLen)
107 bs := buf.GetBytes(nil)
108 actualLen := 0
109 for i := 0; i < len(bs); i++ {
110 actualLen += len(bs[i])
111 }
112 Equal(t, actualLen, expectedLen)
113}
114
115// TestLinkBufferWithZero test more case with n is invalid.
116func TestLinkBufferWithInvalid(t *testing.T) {

Callers

nothing calls this directly

Calls 6

NewLinkBufferFunction · 0.85
WriteBinaryMethod · 0.65
FlushMethod · 0.65
MustNilFunction · 0.50
EqualFunction · 0.50
GetBytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…