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 https://github.com/rust-random/getrandom/pull/298.
This commit is contained in:
Brian Smith
2022-10-21 09:34:31 -07:00
committed by Joe Richey
parent ee0ca47aa2
commit cf85546863
+3
View File
@@ -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());