MCPcopy Create free account
hub / github.com/dgrr/http2 / TestFrameWrite

Function TestFrameWrite

frameHeader_test.go:16–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestFrameWrite(t *testing.T) {
17 fr := AcquireFrameHeader()
18 defer ReleaseFrameHeader(fr)
19
20 data := AcquireFrame(FrameData).(*Data)
21
22 fr.SetBody(data)
23
24 n, err := io.WriteString(data, testStr)
25 if err != nil {
26 t.Fatal(err)
27 }
28 if nn := len(testStr); n != nn {
29 t.Fatalf("unexpected size %d<>%d", n, nn)
30 }
31
32 var bf = bytes.NewBuffer(nil)
33 var bw = bufio.NewWriter(bf)
34 fr.WriteTo(bw)
35 bw.Flush()
36
37 b := bf.Bytes()
38 if str := string(b[9:]); str != testStr {
39 t.Fatalf("mismatch %s<>%s", str, testStr)
40 }
41}
42
43func TestFrameRead(t *testing.T) {
44 var h [9]byte

Callers

nothing calls this directly

Calls 5

AcquireFrameHeaderFunction · 0.85
ReleaseFrameHeaderFunction · 0.85
AcquireFrameFunction · 0.85
SetBodyMethod · 0.80
WriteToMethod · 0.80

Tested by

no test coverage detected