test: unit test to reproduce #33

This commit is contained in:
Chris Hennick 2024-04-23 11:42:32 -07:00
parent 46ff80d294
commit c3d9123abf
No known key found for this signature in database
GPG key ID: DA47AABA4961C509

View file

@ -2210,4 +2210,20 @@ mod test {
writer.finish()?; writer.finish()?;
Ok(()) 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());
}
} }