| 589 | } |
| 590 | |
| 591 | std::vector<std::string> MismatchingNumColumns(int32_t num_cols, int32_t mismatch, |
| 592 | int64_t extra_lines = 0) { |
| 593 | auto write_line = [](int32_t num_cols, std::string_view prefix, std::ostream* out) { |
| 594 | for (int32_t i = 0; i < num_cols; ++i) { |
| 595 | *out << prefix << i << ","; |
| 596 | } |
| 597 | out->seekp(-1, std::ios_base::cur); |
| 598 | *out << "\n"; |
| 599 | }; |
| 600 | |
| 601 | std::stringstream csv_data; |
| 602 | // Output first line with `num_cols` columns |
| 603 | write_line(num_cols, "a", &csv_data); |
| 604 | // Output second line with mismatching number of columns |
| 605 | write_line(num_cols + mismatch, "b", &csv_data); |
| 606 | // Output extra lines with `num_cols` columns each |
| 607 | for (int64_t i = 0; i < extra_lines; ++i) { |
| 608 | write_line(num_cols, "c", &csv_data); |
| 609 | } |
| 610 | return {csv_data.str()}; |
| 611 | } |
| 612 | |
| 613 | TEST(BlockParser, MismatchingNumColumns) { |
| 614 | uint32_t out_size; |