Skip to content

Commit

Permalink
Test getrandom_uninit
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Jun 19, 2024
1 parent 4f103bd commit 51989f6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,16 @@ macro_rules! define_tests {
pub(crate) use define_tests;

define_tests!(crate::getrandom);
mod uninit {
use super::*;

fn wrapper(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
let dest_ptr = dest.as_ptr().cast::<u8>();
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);
}

0 comments on commit 51989f6

Please sign in to comment.