Skip to content

Commit b864a85

Browse files
committed
Test getrandom_uninit
Signed-off-by: Joe Richey <[email protected]>
1 parent 14ba262 commit b864a85

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
@@ -115,3 +115,16 @@ macro_rules! define_tests {
115115
pub(crate) use define_tests;
116116

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

0 commit comments

Comments
 (0)