From 1ba08a0e008d6e76b9a02057572b7aebd21681aa Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 4 Apr 2026 11:00:12 -0600 Subject: [PATCH] Add tests for `From` impls on `Box` and `Vec` --- tests/mod.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/mod.rs b/tests/mod.rs index 9f0e6cb..e9f116a 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -400,6 +400,32 @@ fn slice_as_flattened() { assert_eq!(Array::slice_as_flattened(slice), &[1, 2, 3, 4, 5, 6, 7, 8]); } +#[cfg(feature = "alloc")] +mod allocating { + use super::*; + use typenum::U4; + + #[test] + fn boxed_slice_from_array() { + let array: Array = Array([1, 2, 3, 4]); + let boxed_slice1: Box<[u8]> = Box::from(array); + assert_eq!(&*boxed_slice1, &[1, 2, 3, 4]); + + let boxed_slice2: Box<[u8]> = Box::from(&array); + assert_eq!(&*boxed_slice2, &[1, 2, 3, 4]); + } + + #[test] + fn vec_from_array() { + let array: Array = Array([1, 2, 3, 4]); + let vec1: Vec = Vec::from(array); + assert_eq!(&vec1, &[1, 2, 3, 4]); + + let vec2: Vec = Vec::from(&array); + assert_eq!(&*vec2, &[1, 2, 3, 4]); + } +} + #[test] #[cfg(feature = "zerocopy")] #[allow(unused)]