(t *testing.T)
| 348 | } |
| 349 | |
| 350 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…