diff options
| -rw-r--r-- | alacritty_terminal/src/graphics/sixel.rs | 19 |
1 files 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, ); }; } |