From e70ae57d0940ec97ac4169002b0a32995ecaf337 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 21 Oct 2022 09:34:31 -0700 Subject: [PATCH] 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 https://github.com/rust-random/getrandom/pull/298. --- tests/custom_common/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/custom_common/mod.rs b/tests/custom_common/mod.rs index e5a52991..c4b649fa 100644 --- a/tests/custom_common/mod.rs +++ b/tests/custom_common/mod.rs @@ -10,6 +10,10 @@ pub fn len7_err() -> Error { } fn getrandom_impl(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());