Skip to content

Commit

Permalink
janitor: Fix clippy errors
Browse files Browse the repository at this point in the history
These are reported as errors by clippy (nothing major IMHO), but they
stop clippy from looking at all files, so let's get them out of the way.
  • Loading branch information
hunger committed Jan 16, 2023
1 parent 520df46 commit b767491
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/screenshots/testing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

// cSpell: ignore powf

use std::rc::Rc;

use crossterm::style::Stylize;
Expand Down Expand Up @@ -100,7 +102,7 @@ fn compare_images(
) -> Result<(), String> {
let compare = || {
let reference = image_buffer(reference_path)
.map_err(|image_err| format!("error loading reference image: {:#}", image_err))?;
.map_err(|image_err| format!("error loading reference image: {image_err:#}"))?;

if reference.size() != screenshot.size() {
return Err(format!(
Expand All @@ -126,7 +128,7 @@ fn compare_images(
);
}
}
eprintln!("");
eprintln!();
}

let (failed_pixel_count, max_color_difference) =
Expand Down Expand Up @@ -166,18 +168,14 @@ fn compare_images(
pub fn assert_with_render(path: &str, window: std::rc::Rc<MinimalSoftwareWindow<0>>) {
let rendering = screenshot(window);
if let Err(reason) = compare_images(path, &rendering) {
assert!(false, "Image comparison failure for {}: {}", path, reason);
panic!("Image comparison failure for {path}: {reason}");
}
}

pub fn assert_with_render_by_line(path: &str, window: std::rc::Rc<MinimalSoftwareWindow<0>>) {
let rendering = screenshot_render_by_line(window);
if let Err(reason) = compare_images(path, &rendering) {
assert!(
false,
"Image comparison failure for line-by-line rendering for {}: {}",
path, reason
);
panic!("Image comparison failure for line-by-line rendering for {path}: {reason}");
}
}

Expand All @@ -188,7 +186,7 @@ pub fn screenshot_render_by_line(
let width = size.width;
let height = size.height;

let mut buffer = SharedPixelBuffer::<Rgb8Pixel>::new(width as u32, height as u32);
let mut buffer = SharedPixelBuffer::<Rgb8Pixel>::new(width, height);

// render to buffer
window.request_redraw();
Expand Down

0 comments on commit b767491

Please sign in to comment.