Skip to content

Commit

Permalink
Merge pull request rust-lang#46 from posborne/issue-45-regression-test
Browse files Browse the repository at this point in the history
Regression test for issue rust-lang#45
  • Loading branch information
alexcrichton authored Jul 22, 2016
2 parents 65ac1f6 + 15b59cd commit 0ca3390
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ impl<W: Write> Write for DecoderWriter<W> {
#[cfg(test)]
mod tests {
use std::io::prelude::*;
use std::io;

use rand::{thread_rng, Rng};

Expand Down Expand Up @@ -507,6 +508,18 @@ mod tests {
}
}

#[test]
fn bad_input() {
// regress tests: previously caused a panic on drop
let mut out: Vec<u8> = Vec::new();
let data: Vec<u8> = (0..255).cycle().take(1024).collect();
let mut w = DecoderWriter::new(&mut out);
match w.write_all(&data[..]) {
Ok(_) => panic!("Expected an error to be returned!"),
Err(e) => assert_eq!(e.kind(), io::ErrorKind::InvalidInput),
}
}

#[test]
fn qc_reader() {
::quickcheck::quickcheck(test as fn(_) -> _);
Expand Down

0 comments on commit 0ca3390

Please sign in to comment.