Skip to content

Commit

Permalink
Remove unused error, add new tests, fix one writer implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Wieczoreck authored and elrnv committed Sep 6, 2024
1 parent d1bce11 commit 661f7cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ mod write_vtk_impl {
DataSet(DataSetError),
NewLine,

InvalidColorScalarsType,

/// Generic formatting error originating from [`std::fmt::Error`].
FormatError,
/// Generic IO error originating from [`std::io::Error`].
Expand All @@ -193,10 +191,6 @@ mod write_vtk_impl {
Error::Header(header_err) => write!(f, "Header: {}", header_err),
Error::DataSet(data_set_err) => write!(f, "Data set: {}", data_set_err),
Error::NewLine => write!(f, "New line"),
Error::InvalidColorScalarsType => write!(
f,
"Invalid color scalars type, must be unsigned char or float"
),
Error::FormatError => write!(f, "Format error"),
Error::IOError(kind) => write!(f, "IO Error: {:?}", kind),
}
Expand Down Expand Up @@ -869,8 +863,8 @@ mod write_vtk_impl {
}

match buf {
IOBuffer::Bit(v) => write_buf_impl(v, &mut self.0, |x| x * 255 as u8)?,
IOBuffer::U8(v) => write_buf_impl(v, &mut self.0, |x| x as u8)?,
IOBuffer::Bit(v) => write_buf_impl(v, &mut self.0, |x| x)?,
IOBuffer::U8(v) => write_buf_impl(v, &mut self.0, |x| x)?,
IOBuffer::I8(v) => write_buf_impl(v, &mut self.0, |x| x as u8)?,
IOBuffer::U16(v) => {
write_buf_impl(v, &mut self.0, |x| x as u8)?;
Expand Down Expand Up @@ -1081,6 +1075,10 @@ mod write_vtk_impl {
fn write_buf<BO: ByteOrder>(&mut self, buf: IOBuffer) -> Result {
AsciiWriter(self).write_buf::<BO>(buf)
}

fn write_color_scalars_buf<BO: ByteOrder>(&mut self, buf: IOBuffer) -> Result {
AsciiWriter(self).write_color_scalars_buf::<BO>(buf)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,13 @@ fn cube_complex_test() -> Result {

test!(parse_ne(in1) => ne(&out1));
test_b!(parse_ne(String::new().write_vtk_ne(out1.clone())?.as_bytes()) => ne(&out1));
test_b!(parse_ne(String::new().write_vtk_ne(out1_bin.clone())?.as_bytes()) => ne(&out1));
test_b!(parse_ne(Vec::<u8>::new().write_vtk_ne(out1_bin.clone())?) => ne(&out1_bin));
test_b!(parse_le(Vec::<u8>::new().write_vtk_le(out1_bin.clone())?) => le(&out1_bin));
test_b!(parse_be(Vec::<u8>::new().write_vtk_be(out1_bin.clone())?) => out1_bin);
test_b!(parse_ne(in2) => ne(&out2));
test_b!(parse_ne(String::new().write_vtk_ne(out2.clone())?.as_bytes()) => ne(&out2));
test_b!(parse_ne(String::new().write_vtk_ne(out2_bin.clone())?.as_bytes()) => ne(&out2));
test_b!(parse_le(Vec::<u8>::new().write_vtk_le(out2_bin.clone())?) => le(&out2_bin));
test_b!(parse_be(Vec::<u8>::new().write_vtk_be(out2_bin.clone())?) => out2_bin);
Ok(())
Expand Down

0 comments on commit 661f7cd

Please sign in to comment.