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

Function main

test/unicode_borders.cpp:12–84  ·  view source on GitHub ↗

Regression tests for https://github.com/p-ranav/tabulate/issues/111: Table::use_unicode_borders() should produce clean box-drawing borders without requiring per-row/per-column manual corner configuration.

Source from the content-addressed store, hash-verified

10// Table::use_unicode_borders() should produce clean box-drawing borders
11// without requiring per-row/per-column manual corner configuration.
12int main() {
13 tabulate_test::Harness t;
14 using Row_t = tabulate::Table::Row_t;
15
16 {
17 tabulate::Table table;
18 table.add_row(Row_t{"A", "B"});
19 table.add_row(Row_t{"1", "2"});
20 table.use_unicode_borders();
21 t.expect("outer box only: no lines between rows", table,
22 "\u250c\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2510\n"
23 "\u2502 A \u2502 B \u2502\n"
24 "\u2502 1 \u2502 2 \u2502\n"
25 "\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518");
26 }
27
28 {
29 tabulate::Table table;
30 table.add_row(Row_t{"A", "B"});
31 table.add_row(Row_t{"1", "2"});
32 table.use_unicode_borders(true);
33 t.expect("row separators use T-junctions and a cross, not plain corners", table,
34 "\u250c\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2510\n"
35 "\u2502 A \u2502 B \u2502\n"
36 "\u251c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2524\n"
37 "\u2502 1 \u2502 2 \u2502\n"
38 "\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518");
39 }
40
41 {
42 tabulate::Table table;
43 table.add_row(Row_t{"only"});
44 table.use_unicode_borders();
45 t.expect("a single cell still gets all four distinct corners", table,
46 "\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n"
47 "\u2502 only \u2502\n"
48 "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
49 }
50
51 {
52 tabulate::Table table;
53 table.add_row(Row_t{"col1", "col2"});
54 table.add_row(Row_t{"val1", "val2"});
55 table.use_unicode_borders(true, tabulate::BorderStyle::Heavy);
56 t.expect("BorderStyle::Heavy uses thick box-drawing glyphs", table,
57 "\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501"
58 "\u2513\n"
59 "\u2503 col1 \u2503 col2 \u2503\n"
60 "\u2523\u2501\u2501\u2501\u2501\u2501\u2501\u254b\u2501\u2501\u2501\u2501\u2501\u2501"
61 "\u252b\n"
62 "\u2503 val1 \u2503 val2 \u2503\n"
63 "\u2517\u2501\u2501\u2501\u2501\u2501\u2501\u253b\u2501\u2501\u2501\u2501\u2501\u2501"
64 "\u251b");
65 }
66
67 {
68 tabulate::Table table;
69 table.add_row(Row_t{"col1", "col2"});

Callers

nothing calls this directly

Calls 3

expectMethod · 0.80
reportMethod · 0.80
add_rowMethod · 0.45

Tested by

no test coverage detected