diff --git a/tests/COPYRIGHT b/tests/COPYRIGHT new file mode 100644 index 0000000..064bfe0 --- /dev/null +++ b/tests/COPYRIGHT @@ -0,0 +1,4 @@ +subsubifd.tif: + url: https://data.kitware.com/api/v1/file/hashsum/sha512/372ca32735c8a8fdbe2286dabead9e779da63f10ba81eda84625e5273f76d74ca1a47a978f67e9c00c12f7f72009c7b2c07a641e643bb0c463812f4ae7f15d6e/download + credit: https://github.com/DigitalSlideArchive/tifftools/commit/4d00c70dbce828262f86c1431f7c66b1748965ac + license: CC0 diff --git a/tests/subsubifds.rs b/tests/subsubifds.rs new file mode 100644 index 0000000..fc72e8c --- /dev/null +++ b/tests/subsubifds.rs @@ -0,0 +1,33 @@ +use tiff::{decoder::Decoder, tags::IfdPointer}; + +// This file has the following IFD structure: +// +// ``` +// IFD -> IFD -> IFD +// |-> IFD +// |-> IFD -> IFD +// | \-> IFD -> IFD +// \-> IFD +// ``` +// +// where the main chain of IFD has 3 images, the second of which has several sub-IFDs and some have +// more nested IFDs. +const TEST_IMAGE_SUBIFD: &str = "./tests/subsubifds.tif"; +use std::fs::File; + +#[test] +fn decode_seek_chain() { + let file = File::open(TEST_IMAGE_SUBIFD).expect("Cannot open test image"); + let mut decoder = Decoder::new(file).expect("Invalid format to create decoder"); + + decoder.next_image().unwrap(); + decoder.next_image().unwrap(); + assert!(!decoder.more_images()); + + // Ensure we can seek, to do this again. + decoder.seek_to_image(0) + .expect("Failed to seek to first image"); + decoder.next_image().unwrap(); + decoder.next_image().unwrap(); + assert!(!decoder.more_images()); +} diff --git a/tests/subsubifds.tif b/tests/subsubifds.tif new file mode 100644 index 0000000..51c99d5 Binary files /dev/null and b/tests/subsubifds.tif differ