Skip to content

Commit 1774402

Browse files
committed
fix: improve invalid_data_error macro to support format arguments
1 parent cad002d commit 1774402

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ extern crate alloc;
99

1010
macro_rules! invalid_data_error {
1111
($fmt:expr) => {
12-
invalid_data_error!($fmt, "")
12+
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
1313
};
1414
($fmt:expr, $($arg:tt)*) => {
15-
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
15+
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, format!($fmt, $($arg)*))
1616
};
1717
}
1818

src/zlib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,4 +932,12 @@ mod tests {
932932
];
933933
assert_eq!(buf, decoded_data);
934934
}
935+
936+
#[test]
937+
fn issue_82() {
938+
let encoded_data = [0x00, 0x00];
939+
let error = Header::read_from(&encoded_data[..]).unwrap_err();
940+
assert_eq!(error.kind(), io::ErrorKind::InvalidData);
941+
assert!(error.to_string().contains("method=0"));
942+
}
935943
}

0 commit comments

Comments
 (0)