Skip to content

Commit

Permalink
test: add no padding test
Browse files Browse the repository at this point in the history
  • Loading branch information
wfxr committed Jan 3, 2022
1 parent d53caa5 commit ca15128
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn print(
.delimiter(delimiter as u8)
.has_headers(has_headers)
.from_reader(reader);
let table = CsvTableWriter::new(rdr, 100)?;
let table = CsvTableWriter::new(rdr, 10000)?;
table.writeln(&mut std::io::stdout(), &style)?;
Ok(())
}
26 changes: 26 additions & 0 deletions src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,32 @@ mod test {
Ok(())
}

#[test]
fn test_write_without_padding() -> Result<()> {
let text = "a,b,c\n1,2,3\n4,5,6";
let rdr = ReaderBuilder::new().has_headers(true).from_reader(text.as_bytes());
let wtr = CsvTableWriter::new(rdr, 3)?;
let fmt = TableFormatBuilder::default().padding(0).build();

let mut buf = Vec::new();
wtr.writeln(&mut buf, &fmt)?;

assert_eq!(
"
+-+-+-+
|a|b|c|
+-+-+-+
|1|2|3|
+-+-+-+
|4|5|6|
+-+-+-+
"
.trim_start(),
std::str::from_utf8(&mut buf)?
);
Ok(())
}

#[test]
fn test_write_with_indent() -> Result<()> {
let text = "a,b,c\n1,2,3\n4,5,6";
Expand Down

0 comments on commit ca15128

Please sign in to comment.