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

Function main

test/empty_rows.cpp:9–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "test_utils.hpp"
8
9int main() {
10 tabulate_test::Harness t;
11
12 tabulate::Table single;
13 single.add_row({""});
14 t.expect("one empty cell", single, "+--+\n| |\n+--+");
15
16 tabulate::Table between;
17 between.add_row({"header"});
18 between.add_row({""});
19 between.add_row({"end"});
20 t.expect("empty row between populated rows", between,
21 "+--------+\n| header |\n+--------+\n| |\n+--------+\n| end |\n+--------+");
22
23 tabulate::Table multiple;
24 multiple.add_row({"left", "right"});
25 multiple.add_row({"", ""});
26 multiple.add_row({"end", "done"});
27 t.expect("multiple empty columns", multiple,
28 "+------+-------+\n| left | right |\n+------+-------+\n| | |\n"
29 "+------+-------+\n| end | done |\n+------+-------+");
30
31 tabulate::Table consecutive;
32 consecutive.add_row({""});
33 consecutive.add_row({""});
34 t.expect("consecutive empty rows", consecutive, "+--+\n| |\n+--+\n| |\n+--+");
35
36 tabulate::Table padded;
37 padded.add_row({""});
38 padded[0].format().padding_top(1).padding_bottom(2);
39 t.expect("padding surrounds an empty content line", padded,
40 "+--+\n| |\n| |\n| |\n| |\n+--+");
41
42 tabulate::Table zero_padding;
43 zero_padding.add_row({""});
44 zero_padding[0].format().padding(0);
45 t.expect("zero-width empty cell", zero_padding, "++\n||\n++");
46
47 tabulate::Table height;
48 height.add_row({""});
49 height[0].format().height(3);
50 t.expect("explicit height is preserved", height, "+--+\n| |\n| |\n| |\n+--+");
51
52 tabulate::Table mixed;
53 mixed.add_row({"", "value"});
54 t.expect("mixed empty and nonempty cells", mixed, "+--+-------+\n| | value |\n+--+-------+");
55
56 tabulate::Table nonempty;
57 nonempty.add_row({"value"});
58 t.expect("nonempty control", nonempty, "+-------+\n| value |\n+-------+");
59
60 tabulate::Table multiline;
61 multiline.add_row({"a\nb"});
62 t.expect("multiline control", multiline, "+---+\n| a |\n| b |\n+---+");
63
64 tabulate::Table trailing;
65 trailing.add_row({"a\n"});
66 // Preserve the existing width calculation for trailing/newline-only text.

Callers

nothing calls this directly

Calls 4

expectMethod · 0.80
reportMethod · 0.80
add_rowMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected