summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2018-09-21 15:32:59 +0200
committerPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2018-09-21 15:32:59 +0200
commitdee6df4f336bc82247031f5576bb8d78eb773190 (patch)
tree0e5529944ba9e3bf206d1bb28c1e5a1c12b03c23 /src/lib.rs
parenta1440b5dbb6db5ff6dcdd5a6e4eb27fd5d44ab87 (diff)
cell and row mods become private. Row and Cell are reexported in crate's root
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs84
1 files changed, 6 insertions, 78 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4bf3521..e539b5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,16 +20,16 @@ use std::mem::transmute;
pub use term::{Attr, color};
pub(crate) use term::{Terminal, stdout};
-pub mod cell;
-pub mod row;
+mod cell;
+mod row;
pub mod format;
mod utils;
#[cfg(feature = "csv")]
pub mod csv;
-use row::Row;
-use cell::Cell;
+pub use row::Row;
+pub use cell::Cell;
use format::{TableFormat, LinePosition, consts};
use utils::StringWriter;
@@ -575,8 +575,8 @@ macro_rules! ptable {
mod tests {
use Table;
use Slice;
- use row::Row;
- use cell::Cell;
+ use Row;
+ use Cell;
use format;
use format::consts::{FORMAT_DEFAULT, FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN};
@@ -977,76 +977,4 @@ mod tests {
println!("{}", table.to_string().replace("\r\n","\n"));
assert_eq!(out, table.to_string().replace("\r\n","\n"));
}
-
- #[cfg(feature = "csv")]
- mod csv {
- use Table;
- use row::Row;
- use cell::Cell;
-
- static CSV_S: &'static str = "ABC,DEFG,HIJKLMN\n\
- foobar,bar,foo\n\
- foobar2,bar2,foo2\n";
-
- fn test_table() -> Table {
- let mut table = Table::new();
- table
- .add_row(Row::new(vec![Cell::new("ABC"), Cell::new("DEFG"), Cell::new("HIJKLMN")]));
- table.add_row(Row::new(vec![Cell::new("foobar"), Cell::new("bar"), Cell::new("foo")]));
- table.add_row(Row::new(vec![Cell::new("foobar2"),
- Cell::new("bar2"),
- Cell::new("foo2")]));
- table
- }
-
- #[test]
- fn from() {
- assert_eq!(test_table().to_string().replace("\r\n", "\n"),
- Table::from_csv_string(CSV_S)
- .unwrap()
- .to_string()
- .replace("\r\n", "\n"));
- }
-
- #[test]
- fn to() {
- assert_eq!(
- String::from_utf8(
- test_table()
- .to_csv(Vec::new())
- .unwrap()
- .into_inner()
- .unwrap()
- ).unwrap(),
- CSV_S);
- }
-
- #[test]
- fn trans() {
- assert_eq!(
- Table::from_csv_string(
- &String::from_utf8(
- test_table()
- .to_csv(Vec::new())
- .unwrap()
- .into_inner()
- .unwrap()
- ).unwrap()
- ).unwrap()
- .to_string()
- .replace("\r\n", "\n"),
- test_table().to_string().replace("\r\n", "\n"));
- }
-
- #[test]
- fn extend_table() {
- let mut table = Table::new();
- table.add_row(Row::new(vec![Cell::new("ABC"), Cell::new("DEFG"), Cell::new("HIJKLMN")]));
- table.extend(vec![vec!["A", "B", "C"]]);
- let t2 = table.clone();
- table.extend(t2.rows);
- assert_eq!(table.get_row(1).unwrap().get_cell(2).unwrap().get_content(), "C");
- assert_eq!(table.get_row(2).unwrap().get_cell(1).unwrap().get_content(), "DEFG");
- }
- }
}