Skip to content

Commit

Permalink
Tests: Use custom tests to verify operations on 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 e61f613 commit 302da04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/custom_common/mod.rs
Expand Up @@ -10,6 +10,9 @@ pub fn len7_err() -> Error {
}

fn super_insecure_rng(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 302da04

Please sign in to comment.