From 94eb3d5daccd037967065c2b11c9b0af89d82076 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 30 Jul 2024 22:04:28 -0500 Subject: [PATCH] Fix box_bytes_zst test --- tests/cast_slice_tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/cast_slice_tests.rs b/tests/cast_slice_tests.rs index 0f94f0b..7dbb45e 100644 --- a/tests/cast_slice_tests.rs +++ b/tests/cast_slice_tests.rs @@ -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, _> = 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, _> = 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])); }