From f12886f4c7086a40a150340c12fec253b0183627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Fri, 22 Sep 2023 05:08:10 -0300 Subject: [PATCH] Add new test that exposes existing error --- tests/test.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index e638a90..a087a67 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -58,6 +58,36 @@ fn version() { .is_match(version)); } +#[test] +fn test_compressing_and_decompressing_small_input() { + // Input to be compressed and decompressed + let input: &[u8] = &[1, 2, 3]; + + let compressed = { + let mut output = vec![]; + io::copy( + &mut &*input, + &mut write::Bz3Encoder::new(&mut output, 100 * KB).unwrap(), + ) + .unwrap(); + + output + }; + + let decompressed = { + let mut output = vec![]; + io::copy( + &mut read::Bz3Decoder::new(compressed.as_slice()).unwrap(), + &mut output, + ) + .unwrap(); + + output + }; + + assert_eq!(input, decompressed); +} + #[test] fn test_chained_encoders_and_decoders_with_single_block() { // 100kb gets shrunk down to 22kb-24kb, so it fits in a single 70kb block