1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
mod common;
use std::path::PathBuf;
use wml2::draw::image_from_file;
fn repo_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.to_path_buf()
}
fn error_sample_path(name: &str) -> PathBuf {
repo_root().join(".test").join("errors").join(name)
}
fn decode_error_sample_if_available(name: &str) {
let path = error_sample_path(name);
if !path.is_file() {
eprintln!(
"skipping missing error sample: {name} (configure {})",
common::sample_config_hint().display()
);
return;
}
let image = image_from_file(path.to_string_lossy().into_owned()).unwrap();
assert!(image.width > 0);
assert!(image.height > 0);
}
#[test]
fn decode_56_byte_bmp_header_samples() {
decode_error_sample_if_available("lena-01.bmp");
decode_error_sample_if_available("lena-02.bmp");
decode_error_sample_if_available("lena-03.bmp");
}
#[test]
fn decode_cmyk_jpeg_error_sample() {
decode_error_sample_if_available("cmyk.jpg");
}
#[test]
fn decode_innai_gif_error_sample() {
decode_error_sample_if_available("innai3_gif01.gif");
}