Skip to content

Commit

Permalink
Tests: Use custom tests to verify empty slices are no-ops.
Browse files Browse the repository at this point in the history
Modify the custom tests so that they would have detected and prevented
the issue fixed in rust-random#298.
  • Loading branch information
briansmith committed Oct 21, 2022
1 parent d3ef49d commit e70ae57
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/custom_common/mod.rs
Expand Up @@ -10,6 +10,10 @@ pub fn len7_err() -> Error {
}

fn getrandom_impl(buf: &mut [u8]) -> Result<(), Error> {
// `getrandom` guarantees it will not call any implementation if the output
// buffer is empty.
assert!(!buf.is_empty());

// Length 7 buffers return a custom error
if buf.len() == 7 {
return Err(len7_err());
Expand Down

0 comments on commit e70ae57

Please sign in to comment.