diff options
author | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2016-09-12 11:50:22 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2016-09-12 13:08:13 +0200 |
commit | 0178a2687b3f6e532ea5a290255177f304c1c023 (patch) | |
tree | cab0b796f638c61883534d20e0a8a7d14e67b636 /src/lib.rs | |
parent | 3a8e694c8754c3ce2cdf842b56bee6e02fe14b71 (diff) |
Added UT for unicode separators
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -516,7 +516,8 @@ mod tests { use Slice;
use row::Row;
use cell::Cell;
- use format::consts::{FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN};
+ use format;
+ use format::consts::{FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN};
#[test]
fn table() {
@@ -656,4 +657,35 @@ mod tests { assert_eq!(out, slice.to_string().replace("\r\n", "\n"));
assert_eq!(out, table.slice(1..4).to_string().replace("\r\n", "\n"));
}
+
+ #[test]
+ fn test_unicode_separators() {
+ let mut table = Table::new();
+ table.set_format(
+ format::FormatBuilder::new()
+ .column_separator('|')
+ .borders('|')
+ .separators( &[format::LinePosition::Top], format::LineSeparator::new('─', '┬', '┌', '┐'))
+ .separators( &[format::LinePosition::Intern], format::LineSeparator::new('─', '┼', '├', '┤'))
+ .separators( &[format::LinePosition::Bottom], format::LineSeparator::new('─', '┴', '└', '┘'))
+ .padding(1, 1)
+ .build()
+ );
+ table.add_row(Row::new(vec![Cell::new("1"), Cell::new("1"), Cell::new("1")]));
+ table.add_row(Row::new(vec![Cell::new("2"), Cell::new("2"), Cell::new("2")]));
+ table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")]));
+ let out = "\
+┌────┬────┬────┐
+| t1 | t2 | t3 |
+├────┼────┼────┤
+| 1 | 1 | 1 |
+├────┼────┼────┤
+| 2 | 2 | 2 |
+└────┴────┴────┘
+";
+ println!("{}", out);
+ println!("____");
+ println!("{}", table.to_string().replace("\r\n", "\n"));
+ assert_eq!(out, table.to_string().replace("\r\n", "\n"));
+ }
}
|