forked from openSUSE/snapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable-formatter.cc
53 lines (39 loc) · 1.07 KB
/
table-formatter.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE snapper
#include <boost/test/unit_test.hpp>
#include "../client/utils/TableFormatter.h"
using namespace std;
using namespace snapper;
string
str(const TableFormatter& formatter)
{
ostringstream stream;
stream << formatter;
return stream.str();
}
BOOST_AUTO_TEST_CASE(test1)
{
locale::global(locale("en_GB.UTF-8"));
TableFormatter formatter(Ascii);
formatter.header() = {
{ "Number", TableAlign::RIGHT },
{ "Name EN", TableAlign::LEFT },
{ "Name DE", TableAlign::LEFT },
{ "Square", TableAlign::RIGHT }
};
formatter.rows() = {
{ "0", "zero", "Null", "0" },
{ "1", "one", "Eins", "1"} ,
{ "5", "five", "Fünf", "25" },
{ "12", "twelve", "Zwölf", "144" }
};
string result = {
"Number | Name EN | Name DE | Square\n"
"-------+---------+---------+-------\n"
" 0 | zero | Null | 0\n"
" 1 | one | Eins | 1\n"
" 5 | five | Fünf | 25\n"
" 12 | twelve | Zwölf | 144\n"
};
BOOST_CHECK_EQUAL(str(formatter), result);
}