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 #298.
  • Loading branch information
briansmith authored and josephlr committed Oct 22, 2022
1 parent f9aa8ad commit 1ce58ea
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/custom.rs
Expand Up @@ -16,6 +16,9 @@ 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 1ce58ea

Please sign in to comment.