diff --git a/src/write.rs b/src/write.rs index 985946f1..de2238a7 100644 --- a/src/write.rs +++ b/src/write.rs @@ -156,7 +156,7 @@ impl arbitrary::Arbitrary<'_> for FileOptions { fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result { let mut options = FileOptions { compression_method: CompressionMethod::arbitrary(u)?, - compression_level: Option::::arbitrary(u)?, + compression_level: None, last_modified_time: DateTime::arbitrary(u)?, permissions: Option::::arbitrary(u)?, large_file: bool::arbitrary(u)?, @@ -167,10 +167,15 @@ impl arbitrary::Arbitrary<'_> for FileOptions { #[cfg(feature = "deflate-zopfli")] zopfli_buffer_size: None, }; - #[cfg(feature = "deflate-zopfli")] - if options.compression_method == Deflated - && options.compression_level > Compression::best().level() { - options.zopfli_buffer_size = Some(1 << u.int_in_range(10..=30)?); + if options.compression_method == Deflated { + options.compression_level = Some(u.int_in_range(0..=265)?); + if options.compression_level > Compression::best().level() { + options.zopfli_buffer_size = Some(1 << u.int_in_range(9..=30)?); + } + } else if options.compression_method != Stored { + options.compression_level = Some(u.int_in_range(0..=10)?); + } else if bool::arbitrary(u) { + options.compression_level = Some(1); } u.arbitrary_loop(Some(0), Some((u16::MAX / 4) as u32), |u| { options