MCPcopy
hub / github.com/redis/go-redis / TestReader_ReadStringInto_Large

Function TestReader_ReadStringInto_Large

internal/proto/reader_test.go:350–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

348}
349
350func TestReader_ReadStringInto_Large(t *testing.T) {
351 // Payload deliberately larger than the default bufio buffer (32 KiB)
352 // so we exercise the path where bufio.Reader drains its internal
353 // buffer first and then reads remaining bytes directly into buf.
354 const size = proto.DefaultBufferSize * 4
355 payload := bytes.Repeat([]byte{'a'}, size)
356 src := make([]byte, 0, size+32)
357 src = append(src, []byte(fmt.Sprintf("$%d\r\n", size))...)
358 src = append(src, payload...)
359 src = append(src, '\r', '\n')
360
361 r := proto.NewReader(bytes.NewReader(src))
362 buf := make([]byte, size)
363 n, err := r.ReadStringInto(buf)
364 if err != nil {
365 t.Fatalf("ReadStringInto: %v", err)
366 }
367 if n != size {
368 t.Fatalf("n = %d, want %d", n, size)
369 }
370 if !bytes.Equal(buf[:n], payload) {
371 t.Fatal("payload mismatch")
372 }
373}

Callers

nothing calls this directly

Calls 2

ReadStringIntoMethod · 0.95
NewReaderFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…