Test parsing an unknown field.
This commit is contained in:
parent
02525d42ed
commit
61d78aa197
|
@ -169,4 +169,13 @@ mod tests {
|
||||||
assert_err_pat!(parse_exif(data),
|
assert_err_pat!(parse_exif(data),
|
||||||
Error::InvalidFormat("Unexpected next IFD"));
|
Error::InvalidFormat("Unexpected next IFD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unknown_field() {
|
||||||
|
let data = b"MM\0\x2a\0\0\0\x08\
|
||||||
|
\0\x01\x01\0\xff\xff\0\0\0\x01\0\x14\0\0\0\0\0\0";
|
||||||
|
let (v, _) = parse_exif(data).unwrap();
|
||||||
|
assert_eq!(v.len(), 1);
|
||||||
|
assert_pat!(v[0].value, Value::Unknown(0xffff, 1, 0x140000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,15 @@ macro_rules! assert_ok {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! assert_pat {
|
||||||
|
($expr:expr, $pat:pat) => (
|
||||||
|
match $expr {
|
||||||
|
$pat => {},
|
||||||
|
ref r => panic!("assertion failed: unexpected {:?}", r),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! assert_err_pat {
|
macro_rules! assert_err_pat {
|
||||||
($expr:expr, $variant:pat) => (
|
($expr:expr, $variant:pat) => (
|
||||||
match $expr {
|
match $expr {
|
||||||
|
|
|
@ -457,4 +457,10 @@ mod tests {
|
||||||
fn short_oor() {
|
fn short_oor() {
|
||||||
parse_short::<BigEndian>(b"\x01\x02\x03\x04", 1, 2);
|
parse_short::<BigEndian>(b"\x01\x02\x03\x04", 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unknown() {
|
||||||
|
let (unitlen, _parser) = get_type_info::<BigEndian>(0xffff);
|
||||||
|
assert_eq!(unitlen, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue