Fix box_bytes_zst test (#260)

This commit is contained in:
zachs18 2024-07-31 03:59:13 +00:00 committed by GitHub
parent 20f4a09404
commit e1baf85f09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -357,9 +357,15 @@ fn box_bytes_zst() {
let _: Box<[u8]> = from_box_bytes(x); let _: Box<[u8]> = from_box_bytes(x);
let x: BoxBytes = box_bytes_of(Box::new([0u8; 0])); let x: BoxBytes = box_bytes_of(Box::new([0u8; 0]));
let res: Result<Box<[()]>, _> = try_from_box_bytes(x); let _: Box<[()]> = from_box_bytes(x);
assert_eq!(res.unwrap_err().0, PodCastError::SizeMismatch);
let x: BoxBytes = box_bytes_of(Box::new([(); 0])); let x: BoxBytes = box_bytes_of(Box::new([(); 0]));
let _: Box<[u8]> = from_box_bytes(x); let _: Box<[u8]> = from_box_bytes(x);
let x: BoxBytes = box_bytes_of(Box::new([0u8]));
let res: Result<Box<[()]>, _> = try_from_box_bytes(x);
assert_eq!(res.unwrap_err().0, PodCastError::OutputSliceWouldHaveSlop);
// regression test for dropping zero-sized BoxBytes
let _: BoxBytes = box_bytes_of(Box::new([0u8; 0]));
} }