MCPcopy Create free account
hub / github.com/p-ranav/tabulate / main

Function main

test/streaming_rows.cpp:16–40  ·  view source on GitHub ↗

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().

Source from the content-addressed store, hash-verified

14// the end. With fixed column widths, streaming row-by-row must produce
15// output identical to a normal full print().
16int 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}

Callers

nothing calls this directly

Calls 9

expect_eqMethod · 0.80
reportMethod · 0.80
add_rowMethod · 0.45
widthMethod · 0.45
formatMethod · 0.45
columnMethod · 0.45
print_rowMethod · 0.45
print_bottom_borderMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected