From 5859239922a9b6074ca927722e6d00832d495884 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 18 Dec 2024 21:09:24 +0100 Subject: [PATCH] link PR in the test als use a bit less memory; it's not really needed to prove the point --- src/write.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/write.rs b/src/write.rs index c0fcc3de..f258fe1b 100644 --- a/src/write.rs +++ b/src/write.rs @@ -394,8 +394,11 @@ mod tests { #[test] fn terminate_on_drop() { - // Test that dropping the BzEncoder will result in a valid, decompressable datastream - let s = "12345".repeat(100000); + // Test that dropping the BzEncoder flushes bytes to the output, so that + // we get a valid, decompressable datastream + // + // see https://github.com/trifectatechfoundation/bzip2-rs/pull/121 + let s = "12345".repeat(100); let mut compressed = Vec::new(); { @@ -413,7 +416,7 @@ mod tests { d.finish().unwrap() }; assert_eq!(&uncompressed[0..5], b"12834"); - assert_eq!(uncompressed.len(), 500005); + assert_eq!(uncompressed.len(), s.len() + "12834".len()); assert!(format!("12834{}", s).as_bytes() == &*uncompressed); } }