| 1 |
use tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#; |
| 2 |
|
| 3 |
// This file has the following IFD structure: |
| 4 |
// |
| 5 |
// ``` |
| 6 |
// IFD -> IFD -> IFD |
| 7 |
// |-> IFD |
| 8 |
// |-> IFD -> IFD |
| 9 |
// | \-> IFD -> IFD |
| 10 |
// \-> IFD |
| 11 |
// ``` |
| 12 |
// |
| 13 |
// where the main chain of IFD has 3 images, the second of which has several sub-IFDs and some have |
| 14 |
// more nested IFDs. |
| 15 |
const TEST_IMAGE_SUBIFDrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_SUBIFD.: &str = "./tests/subsubifds.tif"; |
| 16 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#; |
| 17 |
|
| 18 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| •19 |
#[ignore = "skipping, missing test data"] |
| 20 |
fn decode_seek_chainrust-analyzer cargo tiff 0.11.3 decode_seek_chain().() { |
| 21 |
let file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(TEST_IMAGE_SUBIFDrust-analyzer cargo tiff 0.11.3 TEST_IMAGE_SUBIFD.).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Cannot open test image"); |
| 22 |
let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(file).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Invalid format to create decoder"); |
| 23 |
|
| 24 |
// Remember the offsets in the first iteration. |
| 25 |
let offset0 = decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("First IFD pointer not found"); |
| 26 |
decoder.next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 27 |
let offset1 = decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Second IFD pointer not found"); |
| 28 |
decoder.next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 29 |
let offset2 = decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Third IFD pointer not found"); |
| 30 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().decoder.more_imagesrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]more_images().()); |
| 31 |
|
| 32 |
// Ensure we can seek, to do this again. |
| 33 |
decoder |
| 34 |
.seek_to_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]seek_to_image().(0) |
| 35 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to seek to first image"); |
| 36 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset0), decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().()); |
| 37 |
decoder.next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset1), decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().()); |
| 39 |
decoder.next_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]next_image().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 40 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset2), decoder.ifd_pointerrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]ifd_pointer().()); |
| 41 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().decoder.more_imagesrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]more_images().()); |
| 42 |
} |