summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ed15858..1d52824 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -321,7 +321,8 @@ mod tests {
use Table;
use row::Row;
use cell::Cell;
-
+ use format::TableFormat;
+
#[test]
fn table() {
let mut table = Table::new();
@@ -362,4 +363,47 @@ mod tests {
";
assert_eq!(table.to_string().replace("\r\n", "\n"), out);
}
+
+ #[test]
+ fn no_linesep() {
+ let mut table = Table::new();
+ table.set_format(TableFormat::new("|", None, None));
+ 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 |
+";
+ assert_eq!(table.to_string().replace("\r\n", "\n"), out);
+ }
+
+ #[test]
+ fn no_borders() {
+ let mut table = Table::new();
+ table.set_format(TableFormat::new("", None, None));
+ 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, String::from("\n") + &table.to_string().replace("\r\n", "\n"));
+ }
}