From bf743df94214c90708d008debbc66ea36c771c47 Mon Sep 17 00:00:00 2001 From: Ayose Date: Fri, 15 Jul 2022 13:46:27 +0100 Subject: Changes in sixel module to be compatible with oldstable. - Reimplement abs_diff(). - Use positional arguments to format the error message in assert_color!(). --- alacritty_terminal/src/graphics/sixel.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/alacritty_terminal/src/graphics/sixel.rs b/alacritty_terminal/src/graphics/sixel.rs index acad29c8..b3953a93 100644 --- a/alacritty_terminal/src/graphics/sixel.rs +++ b/alacritty_terminal/src/graphics/sixel.rs @@ -643,16 +643,27 @@ mod tests { // We allow some difference between each component to ignore rounding // errors. + // Reimplement abs_diff to be compatible with rustc before 1.60. + fn abs_diff(x: u8, y: u8) -> u8 { + if x > y { + x - y + } else { + y - x + } + } + macro_rules! assert_color { ($h:expr, $l:expr, $s:expr => $r:expr, $g:expr, $b:expr) => { let left = hls_to_rgb($h, $l, $s); let right = rgb($r, $g, $b, 255); assert!( - left.r.abs_diff(right.r) < 4 - && left.g.abs_diff(right.g) < 4 - && left.b.abs_diff(right.b) < 4, - "Expected {right:?} Found {left:?}" + abs_diff(left.r, right.r) < 4 + && abs_diff(left.g, right.g) < 4 + && abs_diff(left.b, right.b) < 4, + "Expected {:?} Found {:?}", + right, + left, ); }; } -- cgit