Skip to content

Commit

Permalink
- added testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Feb 22, 2024
1 parent 50d7bc5 commit 12f4780
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/utils/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Table {
void wrap(int force_break_after = -1);
void set_abbrev(const vector<bool>& abbrev);
void margin(unsigned margin);
void set_screen_width(int screen_width) { _screen_width = screen_width; }

Table ();

Expand Down
32 changes: 32 additions & 0 deletions testsuite/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,35 @@ BOOST_AUTO_TEST_CASE(test1)

check(table, output);
}


BOOST_AUTO_TEST_CASE(test2)
{
locale::global(locale("en_GB.UTF-8"));

Table table;
table.set_screen_width(25);
table.set_abbrev({ false, true });

TableHeader header;
header.add("Number", TableAlign::RIGHT);
header.add("Description");
table.setHeader(header);

TableRow row1;
row1 << "1" << "boot";
table.add(row1);

TableRow row2;
row2 << "2" << "before the system update";
table.add(row2);

vector<string> output = {
"Number | Description ",
"-------+-----------------",
" 1 | boot ",
" 2 | before the sys->"
};

check(table, output);
}

0 comments on commit 12f4780

Please sign in to comment.