Debian Codegraph @

.cargo/vendor/exr/tests/dev.rs

raw
1 //! Contains some "test" functions that were be used for developing.
2
3 extern crate exr;
4 extern crate smallvec;
5
6 use exr::prelude::*;
7
8 use std::path::{PathBuf};
9 use std::ffi::OsStr;
10 use std::io::{Cursor};
11 use exr::meta::header::Header;
12 use exr::image::validate_results::ValidateResult;
13 use rayon::prelude::IntoParallelIterator;
14 use rayon::iter::ParallelIterator;
15
16 fn exr_files() -> impl Iterator<Item=PathBuf> {
17 walkdir::WalkDir::new("tests/images/valid").into_iter().map(std::result::Result::unwrap)
18 .filter(|entry| entry.path().extension() == Some(OsStr::new("exr")))
19 .map(walkdir::DirEntry::into_path)
20 }
21
22 #[test]
23 #[ignore]
24 fn print_meta_of_all_files() {
25 let files: Vec<PathBuf> = exr_files().collect();
26
27 files.into_par_iter().for_each(|path| {
28 let meta = MetaData::read_from_file(&path, false);
29 println!("{:?}: \t\t\t {:?}", path.file_name().unwrap(), meta.unwrap());
30 });
31 }
32
33 #[test]
34 #[ignore]
35 fn search_previews_of_all_files() {
36 let files: Vec<PathBuf> = exr_files().collect();
37
38 files.into_par_iter().for_each(|path| {
39 let meta = MetaData::read_from_file(&path, false).unwrap();
40 let has_preview = meta.headers.iter().any(|header: &Header|
41 header.own_attributes.preview.is_some() || header.own_attributes.other.values()
42 .any(|value| match value { AttributeValue::Preview(_) => true, _ => false })
43 );
44
45 if has_preview {
46 println!("Found preview attribute in {:?}", path.file_name().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 #[test]
54 #[ignore]
55 pub fn 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 println!("{:?}", exr::meta::MetaData::read_from_file(path, true));
72
73 let read_image = read()
74 .no_deep_data().all_resolution_levels().all_channels().all_layers().all_attributes()
75 .non_parallel();
76
77 let image = read_image.clone().from_file(path).unwrap();
78
79 let mut tmp_bytes = Vec::new();
80 image.write().to_buffered(Cursor::new(&mut tmp_bytes)).unwrap();
81 image.write().to_file("debug_pxr24.exr").unwrap();
82
83 let image2 = read_image.from_buffered(Cursor::new(tmp_bytes)).unwrap();
84
85 image.assert_equals_result(&image2);
86 }