Skip to content

Commit

Permalink
Replace issue-159 test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 authored and AlexTMjugador committed Dec 2, 2024
1 parent a85dbf4 commit 2b7b9df
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
Binary file removed tests/files/issue-159.png
Binary file not shown.
Binary file added tests/files/palette_should_be_reduced_with_bkgd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions tests/reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 0 additions & 12 deletions tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2b7b9df

Please sign in to comment.