Skip to content

Commit

Permalink
Fix box_bytes_zst test (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 authored Jul 31, 2024
1 parent 20f4a09 commit e1baf85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/cast_slice_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,15 @@ fn box_bytes_zst() {
let _: Box<[u8]> = from_box_bytes(x);

let x: BoxBytes = box_bytes_of(Box::new([0u8; 0]));
let res: Result<Box<[()]>, _> = try_from_box_bytes(x);
assert_eq!(res.unwrap_err().0, PodCastError::SizeMismatch);
let _: Box<[()]> = from_box_bytes(x);

let x: BoxBytes = box_bytes_of(Box::new([(); 0]));
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]));
}

0 comments on commit e1baf85

Please sign in to comment.