MCPcopy Create free account
hub / github.com/valyala/bytebufferpool / TestByteBufferWriteTo

Function TestByteBufferWriteTo

bytebuffer_test.go:45–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestByteBufferWriteTo(t *testing.T) {
46 expectedS := "foobarbaz"
47 var bb ByteBuffer
48 bb.WriteString(expectedS[:3])
49 bb.WriteString(expectedS[3:])
50
51 wt := (io.WriterTo)(&bb)
52 var w bytes.Buffer
53 for i := 0; i < 10; i++ {
54 n, err := wt.WriteTo(&w)
55 if n != int64(len(expectedS)) {
56 t.Fatalf("unexpected n returned from WriteTo: %d. Expecting %d", n, len(expectedS))
57 }
58 if err != nil {
59 t.Fatalf("unexpected error: %s", err)
60 }
61 s := string(w.Bytes())
62 if s != expectedS {
63 t.Fatalf("unexpected string written %q. Expecting %q", s, expectedS)
64 }
65 w.Reset()
66 }
67}
68
69func TestByteBufferGetPutSerial(t *testing.T) {
70 testByteBufferGetPut(t)

Callers

nothing calls this directly

Calls 4

WriteStringMethod · 0.95
WriteToMethod · 0.80
BytesMethod · 0.80
ResetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…