From d92c600dc7b063e217d8f860e78d2c6e809f4d7e Mon Sep 17 00:00:00 2001 From: Andrew Wock Date: Tue, 5 Mar 2024 14:40:31 -0500 Subject: [PATCH] Extra test --- library/core/tests/mem.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/library/core/tests/mem.rs b/library/core/tests/mem.rs index e1c342f0f3e89..cf7b3856e54bb 100644 --- a/library/core/tests/mem.rs +++ b/library/core/tests/mem.rs @@ -451,6 +451,26 @@ fn uninit_fill_from_partial() { assert_eq!(remainder.len(), 16); } +#[test] +fn uninit_over_fill() { + let mut dst = [MaybeUninit::new(255); 64]; + let src = [0; 72]; + + let (initted, remainder) = MaybeUninit::fill_from(&mut dst, src.into_iter()); + assert_eq!(initted, &src[0..64]); + assert_eq!(remainder.len(), 0); +} + +#[test] +fn uninit_empty_fill() { + let mut dst = [MaybeUninit::new(255); 64]; + let src = [0; 0]; + + let (initted, remainder) = MaybeUninit::fill_from(&mut dst, src.into_iter()); + assert_eq!(initted, &src[0..0]); + assert_eq!(remainder.len(), 64); +} + #[test] #[cfg(panic = "unwind")] fn uninit_fill_from_mid_panic() {