Skip to content

Commit 88e9296

Browse files
committed
Test getrandom_uninit
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent e2cd3f8 commit 88e9296

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
@@ -121,3 +121,16 @@ macro_rules! define_tests {
121121
pub(crate) use define_tests;
122122

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

0 commit comments

Comments
 (0)