tabled/assert/mod.rs
1//! Assert module contains a help macros to compare and test tables conveniently.
2
3/// Create a test function for table assertion.
4///
5/// # Example
6///
7/// ```
8/// # fn main() {}
9///
10/// use tabled::Table;
11/// use tabled::assert::test_table;
12///
13/// test_table!(
14/// test_table,
15/// Table::new([[1, 2, 3], [4, 5, 6]]),
16/// "+---+---+---+"
17/// "| 0 | 1 | 2 |"
18/// "+---+---+---+"
19/// "| 1 | 2 | 3 |"
20/// "+---+---+---+"
21/// "| 4 | 5 | 6 |"
22/// "+---+---+---+"
23/// );
24/// ```
25pub use testing_table::test_table;
26
27/// Assert a table.
28///
29/// It's an analog of [`assert_eq`] but for tables.
30///
31/// # Example
32///
33/// ```
34/// use tabled::Table;
35/// use tabled::assert::assert_table;
36///
37/// let data = [[1, 2, 3], [4, 5, 6]];
38/// let table = Table::new(data);
39///
40/// assert_table!(
41/// table,
42/// "+---+---+---+"
43/// "| 0 | 1 | 2 |"
44/// "+---+---+---+"
45/// "| 1 | 2 | 3 |"
46/// "+---+---+---+"
47/// "| 4 | 5 | 6 |"
48/// "+---+---+---+"
49/// );
50/// ```
51pub use testing_table::assert_table;
52
53/// Assert table width.
54///
55/// # Example
56///
57/// ```
58/// use tabled::Table;
59/// use tabled::assert::assert_width;
60///
61/// let data = [[1, 2, 3], [4, 5, 6]];
62/// let table = Table::new(data);
63///
64/// assert_width!(table, 13);
65/// ```
66pub use testing_table::assert_width;
67
68/// Construct a static table.
69///
70/// Usefull for assert functions.
71///
72/// # Example
73///
74/// ```
75/// use tabled::Table;
76/// use tabled::assert::static_table;
77///
78/// let data = [[1, 2, 3], [4, 5, 6]];
79/// let table = Table::new(data);
80///
81/// assert_eq!(
82/// table.to_string(),
83/// static_table!(
84/// "+---+---+---+"
85/// "| 0 | 1 | 2 |"
86/// "+---+---+---+"
87/// "| 1 | 2 | 3 |"
88/// "+---+---+---+"
89/// "| 4 | 5 | 6 |"
90/// "+---+---+---+"
91/// ),
92/// );
93/// ```
94pub use testing_table::static_table;