Skip to content

Commit 1ce58ea

Browse files
briansmithjosephlr
authored andcommitted
Tests: Use custom tests to verify operations on empty slices are no-ops.
Modify the custom tests so that they would have detected and prevented the issue fixed in #298.
1 parent f9aa8ad commit 1ce58ea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tests/custom.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ fn len7_err() -> Error {
1616
}
1717

1818
fn super_insecure_rng(buf: &mut [u8]) -> Result<(), Error> {
19+
// `getrandom` guarantees it will not call any implementation if the output
20+
// buffer is empty.
21+
assert!(!buf.is_empty());
1922
// Length 7 buffers return a custom error
2023
if buf.len() == 7 {
2124
return Err(len7_err());

0 commit comments

Comments
 (0)