| 1 | //! Contains some "test" functions that were be used for developing. |
| 2 | |
| 3 | extern crate exrrust-analyzer cargo exr 1.74.0 exr/; |
| 4 | extern crate smallvecrust-analyzer cargo exr 1.74.0 smallvec/; |
| 5 | |
| 6 | use exrrust-analyzer cargo exr 1.74.0 crate/::preluderust-analyzer cargo exr 1.74.0 prelude/::*; |
| 7 | |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#}; |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#; |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#}; |
| 11 | use exrrust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::headerrust-analyzer cargo exr 1.74.0 meta/header/::Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#; |
| 12 | use exrrust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::validate_resultsrust-analyzer cargo exr 1.74.0 image/validate_results/::ValidateResultrust-analyzer cargo exr 1.74.0 image/validate_results/ValidateResult#; |
| 13 | use rayonrust-analyzer cargo rayon 1.11.0 crate/::preluderust-analyzer cargo rayon 1.11.0 prelude/::IntoParallelIteratorrust-analyzer cargo rayon 1.11.0 iter/IntoParallelIterator#; |
| 14 | use rayonrust-analyzer cargo rayon 1.11.0 crate/::iterrust-analyzer cargo rayon 1.11.0 iter/::ParallelIteratorrust-analyzer cargo rayon 1.11.0 iter/ParallelIterator#; |
| 15 | |
| 16 | fn exr_filesrust-analyzer cargo exr 1.74.0 exr_files().() -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#=PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 17 | walkdirrust-analyzer cargo walkdir 2.5.0 crate/::WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().("tests/images/valid").into_iterrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().) |
| 18 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|entry| entry.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().().extensionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]extension().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]new().("exr"))) |
| 19 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(walkdirrust-analyzer cargo walkdir 2.5.0 crate/::DirEntryrust-analyzer cargo walkdir 2.5.0 dent/DirEntry#::into_pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]into_path().) |
| 20 | } |
| 21 | |
| 22 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 23 | #[ignore] |
| 24 | fn print_meta_of_all_filesrust-analyzer cargo exr 1.74.0 print_meta_of_all_files().() { |
| 25 | let files: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> = exr_filesrust-analyzer cargo exr 1.74.0 exr_files().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 26 | |
| 27 | files.into_par_iterrust-analyzer cargo rayon 1.11.0 vec/impl#[`Vec<T>`][IntoParallelIterator]into_par_iter().().for_eachrust-analyzer cargo rayon 1.11.0 iter/ParallelIterator#for_each().(|path| { |
| 28 | let meta = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(&path, false); |
| 29 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}: \t\t\t {:?}", path.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), meta.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 34 | #[ignore] |
| 35 | fn search_previews_of_all_filesrust-analyzer cargo exr 1.74.0 search_previews_of_all_files().() { |
| 36 | let files: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> = exr_filesrust-analyzer cargo exr 1.74.0 exr_files().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 37 | |
| 38 | files.into_par_iterrust-analyzer cargo rayon 1.11.0 vec/impl#[`Vec<T>`][IntoParallelIterator]into_par_iter().().for_eachrust-analyzer cargo rayon 1.11.0 iter/ParallelIterator#for_each().(|path| { |
| 39 | let meta = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(&path, false).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 40 | let has_preview = meta.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|header: &Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#| |
| 41 | header.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..previewrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#preview..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() || header.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..otherrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#other..valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().() |
| 42 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|value| match value { AttributeValuerust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#::Previewrust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#Preview#(_) => true, _ => false }) |
| 43 | ); |
| 44 | |
| 45 | if has_preview { |
| 46 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Found preview attribute in {:?}", path.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 47 | } |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | // use this command for big endian testing: |
| 52 | // cross test --target mips-unknown-linux-gnu --verbose --test dev test_roundtrip -- --ignored |
| 53 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 54 | #[ignore] |
| 55 | pub fn test_roundtriprust-analyzer cargo exr 1.74.0 test_roundtrip().() { |
| 56 | // works |
| 57 | //let path = "tests/images/fuzzed/b44_overly_restrictive_assert.exr"; |
| 58 | let path = "tests/images/valid/custom/compression_methods/f32/pxr24.exr"; |
| 59 | |
| 60 | // worksn't |
| 61 | // let path = "tests/images/valid/openexr/Chromaticities/Rec709_YC.exr"; // subsampling |
| 62 | // let path = "tests/images/valid/openexr/LuminanceChroma/Flowers.exr"; // subsampling |
| 63 | |
| 64 | // let path = "tests/images/valid/openexr/IlmfmlmflmTest/test_native1.exr"; |
| 65 | // let path = "tests/images/valid/openexr/IlmfmlmflmTest/test_native2.exr"; // contains NaN |
| 66 | |
| 67 | // deep data? |
| 68 | // let path = "tests/images/valid/openexr/v2/Stereo/Balls.exr"; |
| 69 | // let path = "tests/images/valid/openexr/v2/Stereo/Ground.exr"; |
| 70 | |
| 71 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{:?}", exrrust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(path, true)); |
| 72 | |
| 73 | let read_image = readrust-analyzer cargo exr 1.74.0 image/read/read().() |
| 74 | .no_deep_datarust-analyzer cargo exr 1.74.0 image/read/impl#[ReadBuilder]no_deep_data().().all_resolution_levelsrust-analyzer cargo exr 1.74.0 image/read/samples/impl#[ReadFlatSamples]all_resolution_levels().().all_channelsrust-analyzer cargo exr 1.74.0 image/read/levels/impl#[`ReadAllLevels<ReadDeepOrFlatSamples>`]all_channels().().all_layersrust-analyzer cargo exr 1.74.0 image/read/layers/ReadChannels#all_layers().().all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().() |
| 75 | .non_parallelrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]non_parallel().(); |
| 76 | |
| 77 | let image = read_image.clonerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<OnProgress, ReadLayers>`][Clone]clone().().from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().(path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 78 | |
| 79 | let mut tmp_bytes = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 80 | image.writerust-analyzer cargo exr 1.74.0 image/write/impl#[`&'img Image<WritableLayers>`][`WritableImage<'img, WritableLayers>`]write().().to_bufferedrust-analyzer cargo exr 1.74.0 image/write/impl#[`WriteImageWithOptions<'img, L, F>`]to_buffered().(Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(&mut tmp_bytes)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 81 | image.writerust-analyzer cargo exr 1.74.0 image/write/impl#[`&'img Image<WritableLayers>`][`WritableImage<'img, WritableLayers>`]write().().to_filerust-analyzer cargo exr 1.74.0 image/write/impl#[`WriteImageWithOptions<'img, L, F>`]to_file().("debug_pxr24.exr").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 82 | |
| 83 | let image2 = read_image.from_bufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_buffered().(Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(tmp_bytes)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 84 | |
| 85 | image.assert_equals_resultrust-analyzer cargo exr 1.74.0 image/validate_results/ValidateResult#assert_equals_result().(&image2); |
| 86 | } |