Add test
This commit is contained in:
parent
6763eea1e3
commit
b808807198
2 changed files with 19 additions and 1 deletions
BIN
tests/files/issue-553.png
Normal file
BIN
tests/files/issue-553.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
|
|
@ -4,6 +4,7 @@ use oxipng::*;
|
||||||
use std::fs::remove_file;
|
use std::fs::remove_file;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
const GRAYSCALE: u8 = 0;
|
const GRAYSCALE: u8 = 0;
|
||||||
const RGB: u8 = 2;
|
const RGB: u8 = 2;
|
||||||
|
|
@ -30,7 +31,7 @@ fn test_it_converts(
|
||||||
bit_depth_in: BitDepth,
|
bit_depth_in: BitDepth,
|
||||||
color_type_out: u8,
|
color_type_out: u8,
|
||||||
bit_depth_out: BitDepth,
|
bit_depth_out: BitDepth,
|
||||||
) {
|
) -> PngImage {
|
||||||
let input = PathBuf::from(input);
|
let input = PathBuf::from(input);
|
||||||
let (output, opts) = custom.unwrap_or_else(|| get_opts(&input));
|
let (output, opts) = custom.unwrap_or_else(|| get_opts(&input));
|
||||||
let png = PngData::new(&input, &opts).unwrap();
|
let png = PngData::new(&input, &opts).unwrap();
|
||||||
|
|
@ -71,6 +72,7 @@ fn test_it_converts(
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_file(output).ok();
|
remove_file(output).ok();
|
||||||
|
Arc::try_unwrap(png.raw).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -464,3 +466,19 @@ fn issue_426_02() {
|
||||||
BitDepth::One,
|
BitDepth::One,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_553() {
|
||||||
|
let png = test_it_converts(
|
||||||
|
"tests/files/issue-553.png",
|
||||||
|
None,
|
||||||
|
INDEXED,
|
||||||
|
BitDepth::Eight,
|
||||||
|
INDEXED,
|
||||||
|
BitDepth::Eight,
|
||||||
|
);
|
||||||
|
match png.ihdr.color_type {
|
||||||
|
ColorType::Indexed { palette } => assert_eq!(palette.len(), 256),
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue