From b864a85f8b0a830c4351d5e64504a2c7e52015f0 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Tue, 11 Jun 2024 17:53:26 -0700 Subject: [PATCH] Test getrandom_uninit Signed-off-by: Joe Richey --- src/tests.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tests.rs b/src/tests.rs index 6664e280..32c79c91 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -115,3 +115,16 @@ macro_rules! define_tests { pub(crate) use define_tests; define_tests!(crate::getrandom); +mod uninit { + use super::*; + + fn wrapper(dest: &mut [MaybeUninit]) -> Result<(), Error> { + let dest_ptr = dest.as_ptr().cast::(); + let res = crate::getrandom_uninit(dest)?; + // Ensure that the output points to the same bytes as the input. + assert_eq!(res.as_ptr(), dest_ptr); + assert_eq!(res.len(), dest.len()); + Ok(()) + } + super::define_tests!(wrapper); +}