summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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")]));