Skip to content

Commit

Permalink
Merge branch 'develop' into add-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chalharu committed Dec 26, 2018
2 parents a02145f + a35ff5c commit 8384e69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "compression"
version = "0.1.2"
version = "0.1.3"
authors = ["Mitsuharu Seki <mitsu1986@gmail.com>"]
repository = "https://github.com/chalharu/rust-compression"
keywords = ["compress", "gzip", "deflate", "bzip2", "no_std"]
Expand Down Expand Up @@ -41,4 +41,4 @@ lint = [ "clippy", "all" ]
travis-ci = { repository = "chalharu/rust-compression" }

[package.metadata.docs.rs]
features = ["docs"]
features = ["docs"]
2 changes: 1 addition & 1 deletion src/bzip2/decoder.rs
Expand Up @@ -575,7 +575,7 @@ where
}

let buffer = try!(self.get_next_lfm());
if buffer == self.result_charactor {
if buffer == self.result_charactor && self.result_count < 4 {
self.result_count += 1;
self.result_wrote_count += 1;
} else {
Expand Down
27 changes: 27 additions & 0 deletions src/bzip2/mod.rs
Expand Up @@ -141,4 +141,31 @@ mod tests {
include_bytes!("../../data/sample4.ref"),
);
}

#[test]
fn test_long() {
setup();
let data = b"a".into_iter()
.cycle()
.take(1000)
.cloned()
.collect::<Vec<u8>>();

let compressed = data
.iter()
.cloned()
.encode(&mut BZip2Encoder::new(9), Action::Finish)
.collect::<Result<Vec<_>, _>>();

let decompressed = compressed.unwrap()
.iter()
.cloned()
.decode(&mut BZip2Decoder::new())
.collect::<Result<Vec<_>, _>>();

if let Err(e) = decompressed {
debug!("{}", e);
}
assert_eq!(decompressed, Ok(data));
}
}

0 comments on commit 8384e69

Please sign in to comment.