Skip to content

Commit

Permalink
short buffer test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrh committed Oct 2, 2024
1 parent f41a059 commit b3beeec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/enc/test.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,26 @@ fn test_roundtrip_empty() {
assert_eq!(output_offset, 0);
assert_eq!(compressed_offset, compressed.len());
}

#[cfg(feature="std")]
#[test]
fn test_compress_into_short_buffer() {
use std::io::{Cursor, Write};

// this plaintext should compress to 11 bytes
let plaintext = [0u8; 2048];

// but we only provide space for 10
let mut output_buffer = [0u8; 10];
let mut output_cursor = Cursor::new(&mut output_buffer[..]);

let mut w = crate::CompressorWriter::new(&mut output_cursor,
4096, 4, 22);
w.write(&plaintext).unwrap_err();
w.into_inner();

println!("{output_buffer:?}");
}
/*
Expand Down

0 comments on commit b3beeec

Please sign in to comment.