Replace appropriate uses of assert! with assert_eq! in test suite

This commit is contained in:
Joshua Holmer 2016-05-03 08:03:25 -04:00
parent aaf443fca7
commit a84611c9ae
4 changed files with 90 additions and 90 deletions

View file

@ -58,8 +58,8 @@ fn test_it_converts(input: &Path,
bit_depth_out: png::BitDepth) { bit_depth_out: png::BitDepth) {
let png = png::PngData::new(input, opts.fix_errors).unwrap(); let png = png::PngData::new(input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == color_type_in); assert_eq!(png.ihdr_data.color_type, color_type_in);
assert!(png.ihdr_data.bit_depth == bit_depth_in); assert_eq!(png.ihdr_data.bit_depth, bit_depth_in);
match oxipng::optimize(input, opts) { match oxipng::optimize(input, opts) {
Ok(_) => (), Ok(_) => (),
@ -75,14 +75,14 @@ fn test_it_converts(input: &Path,
} }
}; };
assert!(png.ihdr_data.color_type == color_type_out); assert_eq!(png.ihdr_data.color_type, color_type_out);
assert!(png.ihdr_data.bit_depth == bit_depth_out); assert_eq!(png.ihdr_data.bit_depth, bit_depth_out);
let old_png = image::open(input).unwrap(); let old_png = image::open(input).unwrap();
let new_png = image::open(output).unwrap(); let new_png = image::open(output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();

View file

@ -58,8 +58,8 @@ fn test_it_converts(input: &Path,
bit_depth_out: png::BitDepth) { bit_depth_out: png::BitDepth) {
let png = png::PngData::new(input, opts.fix_errors).unwrap(); let png = png::PngData::new(input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == color_type_in); assert_eq!(png.ihdr_data.color_type, color_type_in);
assert!(png.ihdr_data.bit_depth == bit_depth_in); assert_eq!(png.ihdr_data.bit_depth, bit_depth_in);
match oxipng::optimize(input, opts) { match oxipng::optimize(input, opts) {
Ok(_) => (), Ok(_) => (),
@ -75,14 +75,14 @@ fn test_it_converts(input: &Path,
} }
}; };
assert!(png.ihdr_data.color_type == color_type_out); assert_eq!(png.ihdr_data.color_type, color_type_out);
assert!(png.ihdr_data.bit_depth == bit_depth_out); assert_eq!(png.ihdr_data.bit_depth, bit_depth_out);
let old_png = image::open(input).unwrap(); let old_png = image::open(input).unwrap();
let new_png = image::open(output).unwrap(); let new_png = image::open(output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -139,7 +139,7 @@ fn strip_headers_list() {
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -180,7 +180,7 @@ fn strip_headers_safe() {
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -221,7 +221,7 @@ fn strip_headers_all() {
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -262,7 +262,7 @@ fn strip_headers_none() {
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -277,7 +277,7 @@ fn interlacing_0_to_1() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -293,13 +293,13 @@ fn interlacing_0_to_1() {
} }
}; };
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -314,7 +314,7 @@ fn interlacing_1_to_0() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -330,13 +330,13 @@ fn interlacing_1_to_0() {
} }
}; };
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -351,9 +351,9 @@ fn interlacing_0_to_1_small_files() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -369,15 +369,15 @@ fn interlacing_0_to_1_small_files() {
} }
}; };
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::One); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::One);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -392,9 +392,9 @@ fn interlacing_1_to_0_small_files() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -410,15 +410,15 @@ fn interlacing_1_to_0_small_files() {
} }
}; };
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::One); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::One);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -436,7 +436,7 @@ fn interlaced_0_to_1_other_filter_mode() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -452,13 +452,13 @@ fn interlaced_0_to_1_other_filter_mode() {
} }
}; };
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -491,8 +491,8 @@ fn fix_errors() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == png::ColorType::RGBA); assert_eq!(png.ihdr_data.color_type, png::ColorType::RGBA);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -508,8 +508,8 @@ fn fix_errors() {
} }
}; };
assert!(png.ihdr_data.color_type == png::ColorType::Grayscale); assert_eq!(png.ihdr_data.color_type, png::ColorType::Grayscale);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
// Cannot check if pixels are equal because image crate cannot read corrupt (input) PNGs // Cannot check if pixels are equal because image crate cannot read corrupt (input) PNGs
remove_file(output).ok(); remove_file(output).ok();

View file

@ -58,9 +58,9 @@ fn test_it_converts(input: &Path,
bit_depth_out: png::BitDepth) { bit_depth_out: png::BitDepth) {
let png = png::PngData::new(input, opts.fix_errors).unwrap(); let png = png::PngData::new(input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == color_type_in); assert_eq!(png.ihdr_data.color_type, color_type_in);
assert!(png.ihdr_data.bit_depth == bit_depth_in); assert_eq!(png.ihdr_data.bit_depth, bit_depth_in);
assert!(png.ihdr_data.interlaced == 1); assert_eq!(png.ihdr_data.interlaced, 1);
match oxipng::optimize(input, opts) { match oxipng::optimize(input, opts) {
Ok(_) => (), Ok(_) => (),
@ -76,14 +76,14 @@ fn test_it_converts(input: &Path,
} }
}; };
assert!(png.ihdr_data.color_type == color_type_out); assert_eq!(png.ihdr_data.color_type, color_type_out);
assert!(png.ihdr_data.bit_depth == bit_depth_out); assert_eq!(png.ihdr_data.bit_depth, bit_depth_out);
let old_png = image::open(input).unwrap(); let old_png = image::open(input).unwrap();
let new_png = image::open(output).unwrap(); let new_png = image::open(output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();

View file

@ -58,9 +58,9 @@ fn test_it_converts(input: &Path,
bit_depth_out: png::BitDepth) { bit_depth_out: png::BitDepth) {
let png = png::PngData::new(input, opts.fix_errors).unwrap(); let png = png::PngData::new(input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == color_type_in); assert_eq!(png.ihdr_data.color_type, color_type_in);
assert!(png.ihdr_data.bit_depth == bit_depth_in); assert_eq!(png.ihdr_data.bit_depth, bit_depth_in);
assert!(png.ihdr_data.interlaced == 0); assert_eq!(png.ihdr_data.interlaced, 0);
match oxipng::optimize(input, opts) { match oxipng::optimize(input, opts) {
Ok(_) => (), Ok(_) => (),
@ -76,14 +76,14 @@ fn test_it_converts(input: &Path,
} }
}; };
assert!(png.ihdr_data.color_type == color_type_out); assert_eq!(png.ihdr_data.color_type, color_type_out);
assert!(png.ihdr_data.bit_depth == bit_depth_out); assert_eq!(png.ihdr_data.bit_depth, bit_depth_out);
let old_png = image::open(input).unwrap(); let old_png = image::open(input).unwrap();
let new_png = image::open(output).unwrap(); let new_png = image::open(output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -1283,9 +1283,9 @@ fn palette_should_be_reduced_with_dupes() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 43 * 3); assert_eq!(png.palette.unwrap().len(), 43 * 3);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -1301,15 +1301,15 @@ fn palette_should_be_reduced_with_dupes() {
} }
}; };
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 35 * 3); assert_eq!(png.palette.unwrap().len(), 35 * 3);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -1323,9 +1323,9 @@ fn palette_should_be_reduced_with_unused() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 35 * 3); assert_eq!(png.palette.unwrap().len(), 35 * 3);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -1341,15 +1341,15 @@ fn palette_should_be_reduced_with_unused() {
} }
}; };
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 33 * 3); assert_eq!(png.palette.unwrap().len(), 33 * 3);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();
@ -1363,9 +1363,9 @@ fn palette_should_be_reduced_with_both() {
let png = png::PngData::new(&input, opts.fix_errors).unwrap(); let png = png::PngData::new(&input, opts.fix_errors).unwrap();
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 43 * 3); assert_eq!(png.palette.unwrap().len(), 43 * 3);
match oxipng::optimize(&input, &opts) { match oxipng::optimize(&input, &opts) {
Ok(_) => (), Ok(_) => (),
@ -1381,15 +1381,15 @@ fn palette_should_be_reduced_with_both() {
} }
}; };
assert!(png.ihdr_data.color_type == png::ColorType::Indexed); assert_eq!(png.ihdr_data.color_type, png::ColorType::Indexed);
assert!(png.ihdr_data.bit_depth == png::BitDepth::Eight); assert_eq!(png.ihdr_data.bit_depth, png::BitDepth::Eight);
assert!(png.palette.unwrap().len() == 33 * 3); assert_eq!(png.palette.unwrap().len(), 33 * 3);
let old_png = image::open(&input).unwrap(); let old_png = image::open(&input).unwrap();
let new_png = image::open(&output).unwrap(); let new_png = image::open(&output).unwrap();
// Conversion should be lossless // Conversion should be lossless
assert!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>() == assert_eq!(old_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>(),
new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>()); new_png.pixels().map(|x| x.2.channels().to_owned()).collect::<Vec<Vec<u8>>>());
remove_file(output).ok(); remove_file(output).ok();