From c3d9123abf43795659df9b3bb247622f0b0b1d67 Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Tue, 23 Apr 2024 11:42:32 -0700 Subject: [PATCH] test: unit test to reproduce #33 --- src/write.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/write.rs b/src/write.rs index 579ef0154..5d85d5ad6 100644 --- a/src/write.rs +++ b/src/write.rs @@ -2210,4 +2210,20 @@ mod test { writer.finish()?; Ok(()) } + + #[test] + fn test_alignment() { + let page_size = 4096; + let options = SimpleFileOptions::default() + .compression_method(CompressionMethod::Stored) + .with_alignment(page_size); + let mut zip = ZipWriter::new(io::Cursor::new(Vec::new())); + let contents = b"sleeping"; + let () = zip.start_file("sleep", options).unwrap(); + let _count = zip.write(&contents[..]).unwrap(); + let mut zip = ZipArchive::new(zip.finish().unwrap()).unwrap(); + let file = zip.by_index(0).unwrap(); + assert_eq!(file.name(), "sleep"); + assert_eq!(file.data_start(), page_size.into()); + } }