| 585 | } |
| 586 | |
| 587 | void AccumulateReads(const std::shared_ptr<InputStream>& stream, |
| 588 | std::function<int64_t()> gen_chunk_sizes, |
| 589 | std::shared_ptr<Buffer>* out) { |
| 590 | std::vector<std::shared_ptr<Buffer>> buffers; |
| 591 | int64_t total_size = 0; |
| 592 | while (true) { |
| 593 | const int64_t chunk_size = gen_chunk_sizes(); |
| 594 | ASSERT_OK_AND_ASSIGN(auto buf, stream->Read(chunk_size)); |
| 595 | const int64_t buf_size = buf->size(); |
| 596 | total_size += buf_size; |
| 597 | ASSERT_OK_AND_EQ(total_size, stream->Tell()); |
| 598 | if (chunk_size > 0 && buf_size == 0) { |
| 599 | // EOF |
| 600 | break; |
| 601 | } |
| 602 | buffers.push_back(std::move(buf)); |
| 603 | if (buf_size < chunk_size) { |
| 604 | // Short read should imply EOF on next read |
| 605 | ASSERT_OK_AND_ASSIGN(auto buf, stream->Read(100)); |
| 606 | ASSERT_EQ(buf->size(), 0); |
| 607 | break; |
| 608 | } |
| 609 | } |
| 610 | ASSERT_OK_AND_ASSIGN(*out, ConcatenateBuffers(buffers)); |
| 611 | } |
| 612 | |
| 613 | void AccumulateReads(const std::shared_ptr<InputStream>& stream, int64_t chunk_size, |
| 614 | std::shared_ptr<Buffer>* out) { |
nothing calls this directly
no test coverage detected