diff options
author | Hendrik Sollich <hendrik@hoodie.de> | 2015-11-24 18:37:06 +0100 |
---|---|---|
committer | Hendrik Sollich <hendrik@hoodie.de> | 2015-11-24 18:37:06 +0100 |
commit | 526c2664c9a1f484d83892132bdc04a39ce06b02 (patch) | |
tree | bef2f02cd7b582c9a1229617a132007aff5d16f3 /src/lib.rs | |
parent | 35665ce05f37e75729c98e47542b0bb3ebabb370 (diff) |
allowing for NO colum separators
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 46 |
1 files changed, 45 insertions, 1 deletions
@@ -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"));
+ }
}
|