Skip to content

Commit 51989f6

Browse files
committed
Test getrandom_uninit
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 4f103bd commit 51989f6

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,16 @@ macro_rules! define_tests {
114114
pub(crate) use define_tests;
115115

116116
define_tests!(crate::getrandom);
117+
mod uninit {
118+
use super::*;
119+
120+
fn wrapper(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
121+
let dest_ptr = dest.as_ptr().cast::<u8>();
122+
let res = crate::getrandom_uninit(dest)?;
123+
// Ensure that the output points to the same bytes as the input.
124+
assert_eq!(res.as_ptr(), dest_ptr);
125+
assert_eq!(res.len(), dest.len());
126+
Ok(())
127+
}
128+
super::define_tests!(wrapper);
129+
}

0 commit comments

Comments
 (0)