Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp committed Sep 9, 2024
1 parent c81aee5 commit 0373ab8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Binary file added samples/samplepptx.pptx
Binary file not shown.
40 changes: 25 additions & 15 deletions tests/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use std::path::Path;
use std::{mem, ptr};

use libdeflate_sys::{libdeflate_alloc_compressor, libdeflate_deflate_compress};
use preflate_rs::{decompress_deflate_stream, recompress_deflate_stream};
use preflate_rs::{
compress_zstd, decompress_deflate_stream, decompress_zstd, recompress_deflate_stream,
};

#[cfg(test)]
pub fn read_file(filename: &str) -> Vec<u8> {
Expand Down Expand Up @@ -48,31 +50,39 @@ fn test_pptxplaintext() {
}

#[test]
#[ignore = "chain length too long"]
fn test_dumpout() {
verifyresult(&read_file("dumpout-29473.deflate"));
fn test_nomatch() {
test_file("sample2.bin");
}

#[test]
#[ignore = "chain length too long"]
fn test_dumpout2() {
verifyresult(&read_file("dumpout-355865.deflate"));
fn test_sample1() {
test_file("sample1.bin");
}

#[test]
fn test_nomatch() {
test_file("sample2.bin");
fn test_samplezip() {
test_container("samplezip.zip");
}

#[test]
#[ignore = "chain length too long"]
fn test_treedeflate() {
verifyresult(&read_file("treepng.deflate"));
fn test_docx() {
test_container("samplepptx.pptx");
}

#[test]
fn test_sample1() {
test_file("sample1.bin");
fn test_container(filename: &str) {
let v = read_file(filename);
let c = compress_zstd(&v).unwrap();

let r = decompress_zstd(&c, 1024 * 1024 * 128).unwrap();
assert!(v == r);

println!(
"file {} original size: {}, compressed size: {} (plaintext={})",
filename,
v.len(),
c.len(),
r.len()
);
}

#[test]
Expand Down

0 comments on commit 0373ab8

Please sign in to comment.