swf: Add tests for errors on incorrect parse
This commit is contained in:
parent
3058b88011
commit
93a221aea4
|
@ -404,6 +404,19 @@ pub mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// Ensure that we return an error on invalid data.
|
||||
#[test]
|
||||
fn read_parse_error() {
|
||||
let action_bytes = [0xff, 0xff, 0xff, 0x00, 0x00];
|
||||
let mut reader = Reader::new(&action_bytes[..], 5);
|
||||
match reader.read_action() {
|
||||
Err(crate::error::Error::Avm1ParseError { .. }) => (),
|
||||
result => {
|
||||
panic!("Expected Avm1ParseError, got {:?}", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_define_function() {
|
||||
// Ensure we read a function properly along with the function data.
|
||||
|
|
|
@ -3136,4 +3136,17 @@ pub mod tests {
|
|||
assert_eq!(reader.read_tag_list().unwrap(), [Tag::ShowFrame]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensure that we return an error on invalid data.
|
||||
#[test]
|
||||
fn read_invalid_tag() {
|
||||
let tag_bytes = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff];
|
||||
let mut reader = Reader::new(&tag_bytes[..], 5);
|
||||
match reader.read_tag() {
|
||||
Err(crate::error::Error::SwfParseError { .. }) => (),
|
||||
result => {
|
||||
panic!("Expected SwfParseError, got {:?}", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue