[librsvg] compare_to_surface(): Print how many pixels were different, and add a tolerance
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] compare_to_surface(): Print how many pixels were different, and add a tolerance
- Date: Tue, 26 Mar 2019 22:22:53 +0000 (UTC)
commit c3937373410ebc891a6727a7dc7754eb906b1e89
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Mar 26 15:53:22 2019 -0600
compare_to_surface(): Print how many pixels were different, and add a tolerance
librsvg_crate/tests/utils/mod.rs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/librsvg_crate/tests/utils/mod.rs b/librsvg_crate/tests/utils/mod.rs
index 51c618af..d2cfbf75 100644
--- a/librsvg_crate/tests/utils/mod.rs
+++ b/librsvg_crate/tests/utils/mod.rs
@@ -117,6 +117,8 @@ pub fn compare_to_file(
}
}
+const MAX_DIFF: u8 = 2;
+
pub fn compare_to_surface(
output_surf: &SharedImageSurface,
reference_surf: &SharedImageSurface,
@@ -143,7 +145,15 @@ pub fn compare_to_surface(
let mut output_file = File::create(diff_path).unwrap();
surf.write_to_png(&mut output_file).unwrap();
- assert_eq!(diff.num_pixels_changed, 0);
+ if diff.num_pixels_changed != 0 && diff.max_diff > MAX_DIFF {
+ println!(
+ "{}: {} pixels changed with maximum difference of {}",
+ output_base_name,
+ diff.num_pixels_changed,
+ diff.max_diff,
+ );
+ unreachable!("surfaces are too different");
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]