| 43 | |
| 44 | template <typename IntContainer> |
| 45 | void AssertChunking(Chunker& chunker, const std::string& str, |
| 46 | const IntContainer& expected_lengths) { |
| 47 | uint32_t expected_chunk_size; |
| 48 | |
| 49 | // First chunkize whole CSV block |
| 50 | expected_chunk_size = static_cast<uint32_t>( |
| 51 | std::accumulate(expected_lengths.begin(), expected_lengths.end(), 0ULL)); |
| 52 | AssertChunkSize(chunker, str, expected_chunk_size); |
| 53 | |
| 54 | // Then chunkize incomplete substrings of the block |
| 55 | expected_chunk_size = 0; |
| 56 | for (const auto length : expected_lengths) { |
| 57 | AssertChunkSize(chunker, str.substr(0, expected_chunk_size + length - 1), |
| 58 | expected_chunk_size); |
| 59 | |
| 60 | expected_chunk_size += static_cast<uint32_t>(length); |
| 61 | AssertChunkSize(chunker, str.substr(0, expected_chunk_size), expected_chunk_size); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | class BaseChunkerTest : public ::testing::TestWithParam<bool> { |
| 66 | protected: |
no test coverage detected