summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhcpl <hcpl.prog@gmail.com>2017-06-04 09:32:42 +0300
committerhcpl <hcpl.prog@gmail.com>2017-06-04 09:32:42 +0300
commit766cf017cd3744598e6267c060ce7565548a5168 (patch)
treebadaabff04ef1ba9c42501d8f469f546f06a2452 /src
parent367118a83c06cac72f6c9ce3d87b0fb6f00075ec (diff)
Add tests regarding padding
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f3111e9..c0184bd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -603,7 +603,7 @@ mod tests {
use row::Row;
use cell::Cell;
use format;
- use format::consts::{FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN};
+ use format::consts::{FORMAT_DEFAULT, FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN};
#[test]
fn table() {
@@ -719,6 +719,35 @@ mod tests {
}
#[test]
+ fn padding() {
+ let mut table = Table::new();
+ let mut format = *FORMAT_DEFAULT;
+ format.padding(2, 2);
+ table.set_format(format);
+ table.add_row(Row::new(vec![Cell::new("a"), Cell::new("bc"), Cell::new("def")]));
+ table.add_row(Row::new(vec![Cell::new("def"), Cell::new("bc"), Cell::new("a")]));
+ table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")]));
+ assert_eq!(table[1][1].get_content(), "bc");
+
+ table[1][1] = Cell::new("newval");
+ assert_eq!(table[1][1].get_content(), "newval");
+
+ let out = "\
++-------+----------+-------+
+| t1 | t2 | t3 |
++=======+==========+=======+
+| a | bc | def |
++-------+----------+-------+
+| def | newval | a |
++-------+----------+-------+
+";
+ println!("{}", out);
+ println!("____");
+ println!("{}", table.to_string().replace("\r\n", "\n"));
+ assert_eq!(out, table.to_string().replace("\r\n", "\n"));
+ }
+
+ #[test]
fn slices() {
let mut table = Table::new();
table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")]));