Skip to content

Commit e70ae57

Browse files
committed
Tests: Use custom tests to verify empty slices are no-ops.
Modify the custom tests so that they would have detected and prevented the issue fixed in rust-random#298.
1 parent d3ef49d commit e70ae57

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/custom_common/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ pub fn len7_err() -> Error {
1010
}
1111

1212
fn getrandom_impl(buf: &mut [u8]) -> Result<(), Error> {
13+
// `getrandom` guarantees it will not call any implementation if the output
14+
// buffer is empty.
15+
assert!(!buf.is_empty());
16+
1317
// Length 7 buffers return a custom error
1418
if buf.len() == 7 {
1519
return Err(len7_err());

0 commit comments

Comments
 (0)