Replace issue-159 test
This commit is contained in:
parent
a85dbf4880
commit
2b7b9df777
4 changed files with 39 additions and 12 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB |
BIN
tests/files/palette_should_be_reduced_with_bkgd.png
Normal file
BIN
tests/files/palette_should_be_reduced_with_bkgd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 422 B |
|
|
@ -1048,6 +1048,45 @@ fn palette_should_be_reduced_with_unused() {
|
|||
remove_file(output).ok();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn palette_should_be_reduced_with_bkgd() {
|
||||
let input = PathBuf::from("tests/files/palette_should_be_reduced_with_bkgd.png");
|
||||
let (output, opts) = get_opts(&input);
|
||||
|
||||
let png = PngData::new(&input, &opts).unwrap();
|
||||
|
||||
assert_eq!(png.raw.ihdr.color_type.png_header_code(), INDEXED);
|
||||
assert_eq!(png.raw.ihdr.bit_depth, BitDepth::One);
|
||||
assert_eq!(&png.aux_chunks[0].name, b"bKGD");
|
||||
if let ColorType::Indexed { palette } = &png.raw.ihdr.color_type {
|
||||
assert_eq!(palette.len(), 3);
|
||||
}
|
||||
|
||||
match oxipng::optimize(&InFile::Path(input), &output, &opts) {
|
||||
Ok(_) => (),
|
||||
Err(x) => panic!("{}", x),
|
||||
};
|
||||
let output = output.path().unwrap();
|
||||
assert!(output.exists());
|
||||
|
||||
let png = match PngData::new(output, &opts) {
|
||||
Ok(x) => x,
|
||||
Err(x) => {
|
||||
remove_file(output).ok();
|
||||
panic!("{}", x)
|
||||
}
|
||||
};
|
||||
|
||||
assert_eq!(png.raw.ihdr.color_type.png_header_code(), INDEXED);
|
||||
assert_eq!(png.raw.ihdr.bit_depth, BitDepth::One);
|
||||
assert_ne!(&png.aux_chunks[0].name, b"bKGD");
|
||||
if let ColorType::Indexed { palette } = &png.raw.ihdr.color_type {
|
||||
assert_eq!(palette.len(), 2);
|
||||
}
|
||||
|
||||
remove_file(output).ok();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn palette_should_be_reduced_with_both() {
|
||||
let input = PathBuf::from("tests/files/palette_should_be_reduced_with_both.png");
|
||||
|
|
|
|||
|
|
@ -161,18 +161,6 @@ fn issue_140() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_159() {
|
||||
test_it_converts(
|
||||
"tests/files/issue-159.png",
|
||||
None,
|
||||
INDEXED,
|
||||
BitDepth::One,
|
||||
INDEXED,
|
||||
BitDepth::One,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_171() {
|
||||
test_it_converts(
|
||||
|
|
|
|||
Loading…
Reference in a new issue