Skip to content

Commit

Permalink
Merge remote-tracking branch 'pr/add-test-for-new-error'
Browse files Browse the repository at this point in the history
  • Loading branch information
bczhc committed Sep 22, 2023
2 parents ddc43b4 + f12886f commit 4c3a8dd
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c3a8dd

Please sign in to comment.