Skip to content

Commit 05baf46

Browse files
committed
Test getrandom_uninit
Signed-off-by: Joe Richey <[email protected]>
1 parent f92ad31 commit 05baf46

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/tests.rs

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

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

0 commit comments

Comments
 (0)