Regression test for https://github.com/p-ranav/tabulate/issues/62: Table::print_row()/print_bottom_border() let rows be streamed to a stream as they're added, instead of only printing the whole table once at the end. With fixed column widths, streaming row-by-row must produce output identical to a normal full print().
| 14 | // the end. With fixed column widths, streaming row-by-row must produce |
| 15 | // output identical to a normal full print(). |
| 16 | int main() { |
| 17 | tabulate_test::Harness t; |
| 18 | using Row_t = tabulate::Table::Row_t; |
| 19 | |
| 20 | tabulate::Table table; |
| 21 | table.add_row(Row_t{"ID", "Status"}); |
| 22 | table.column(0).format().width(6); |
| 23 | table.column(1).format().width(10); |
| 24 | |
| 25 | std::ostringstream streamed; |
| 26 | table.print_row(0, streamed); |
| 27 | |
| 28 | table.add_row(Row_t{"1", "OK"}); |
| 29 | table.print_row(1, streamed); |
| 30 | |
| 31 | table.add_row(Row_t{"2", "FAILED"}); |
| 32 | table.print_row(2, streamed); |
| 33 | |
| 34 | table.print_bottom_border(streamed); |
| 35 | |
| 36 | t.expect_eq("streaming rows one at a time matches a normal full print()", streamed.str(), |
| 37 | table.str() + "\n"); |
| 38 | |
| 39 | return t.report(); |
| 40 | } |