Skip to content

Commit

Permalink
Test truncated files
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 22, 2024
1 parent a0700f4 commit b4d2fd3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/stall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ fn decode(data: &[u8]) -> Result<(), gif::DecodingError> {
Ok(())
}

#[test]
fn test_truncated_file() {
let data = include_bytes!("../tests/samples/anim-gr.gif");
for len in 0..data.len()-1 {

let truncated = &data[..len];
// it's expected to fail often, but should not stall or panic
if let Ok(d) = gif::DecodeOptions::new().read_info(truncated) {
let _ = d.into_iter().take_while(|f| f.is_ok()).count();
}
}
}

#[test]
fn one_byte_at_a_time() {
let r = OneByte {
Expand Down

0 comments on commit b4d2fd3

Please sign in to comment.