Skip to content

Commit

Permalink
Make lzma test case pass
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Jan 26, 2024
1 parent f480928 commit 7038eb1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 180 deletions.
177 changes: 2 additions & 175 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/rc-zip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ flate2 = { version = "1.0.28", optional = true }
num_enum = "0.7.2"
byteorder = "1.5.0"
cfg-if = "1.0.0"
# lzma-rs = { version = "0.3.0", features = ["raw_decoder", "enable_logging"], optional = true }
lzma-rs = { path = "../../../lzma-rs", features = ["raw_decoder", "stream", "enable_logging"], optional = true }
lzma-rs = { version = "0.3.0", features = ["stream"], optional = true }

[features]
default = ["sync", "file", "deflate"]
Expand Down
4 changes: 2 additions & 2 deletions crates/rc-zip/src/reader/sync/entry_reader/lzma_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
};

enum LzmaDecoderState {
Writing(Stream<Vec<u8>>),
Writing(Box<Stream<Vec<u8>>>),
Draining(Vec<u8>),
Transition,
}
Expand Down Expand Up @@ -163,6 +163,6 @@ pub(crate) fn mk_decoder(
Ok(Box::new(LzmaDecoderAdapter {
input: r,
total_write_count: 0,
state: LzmaDecoderState::Writing(stream),
state: LzmaDecoderState::Writing(Box::new(stream)),
}))
}
6 changes: 5 additions & 1 deletion crates/rc-zip/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ impl ZipTestFile {
// ah well
}
FileContent::Bytes(expected_bytes) => {
// first check length
assert_eq!(actual_bytes.len(), expected_bytes.len());
assert_eq!(&actual_bytes[..], &expected_bytes[..])
}
FileContent::File(file_path) => {
let expected_bytes = std::fs::read(zips_dir().join(file_path)).unwrap();
// first check length
assert_eq!(actual_bytes.len(), expected_bytes.len());
assert_eq!(&actual_bytes[..], &expected_bytes[..])
}
}
Expand Down Expand Up @@ -272,7 +276,7 @@ fn test_cases() -> Vec<ZipTest> {
expected_encoding: Some(Encoding::Utf8),
files: vec![ZipTestFile {
name: "found-me.txt",
content: FileContent::Bytes("Oh no, you found me!\n".repeat(5000).into()),
content: FileContent::Bytes("Oh no, you found me\n".repeat(5000).into()),
modified: Some(date((2024, 1, 26), (17, 14, 36), 0, time_zone(0)).unwrap()),
..Default::default()
}],
Expand Down

0 comments on commit 7038eb1

Please sign in to comment.