From d61fe362373faa343539d96b9d78136ee37692c9 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sun, 4 Oct 2020 15:27:49 -0700 Subject: [PATCH] Improve pos io test coverage --- src/blob/pos_io.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/blob/pos_io.rs b/src/blob/pos_io.rs index 4bc3fa1..c3069d2 100644 --- a/src/blob/pos_io.rs +++ b/src/blob/pos_io.rs @@ -241,6 +241,20 @@ mod test { blob.read_at_exact(&mut s, 0).unwrap(); assert_eq!(&s, &[1u8, 2, 3, 4, 5, 16, 17, 18, 19, 20]); + let mut s2: [std::mem::MaybeUninit; 10] = [std::mem::MaybeUninit::uninit(); 10]; + { + let read = blob.raw_read_at_exact(&mut s2, 0).unwrap(); + assert_eq!(read, &s); + assert!(std::ptr::eq(read.as_ptr(), s2.as_ptr().cast())); + } + + let mut empty = []; + assert!(std::ptr::eq( + blob.raw_read_at_exact(&mut empty, 0).unwrap().as_ptr(), + empty.as_ptr().cast(), + )); + assert!(blob.raw_read_at_exact(&mut s2, 5).is_err()); + let end_pos = blob.seek(std::io::SeekFrom::Current(0)).unwrap(); assert_eq!(end_pos, 1); }