From df3f18329e9ab44b19248e6a2fc85708140b2263 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 3 Nov 2026 23:44:55 +0100 Subject: [PATCH] Trace: cover the column pass and mixed pairs in the smoothing tests (#5454) Co-Authored-By: Claude Sonnet 5.5 --- crates/trace/src/smooth.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/trace/src/smooth.rs b/crates/trace/src/smooth.rs index 070bd82e1..c449f4f9a 100644 --- a/crates/trace/src/smooth.rs +++ b/crates/trace/src/smooth.rs @@ -195,8 +195,11 @@ mod tests { let weights = weight_table(); for p in 0..=255u8 { for q in 0..=255u8 { - let src = [p, p, p, 255, q, q, q, 255]; - assert_eq!(pass(&src, 2, 1, true, &weights), reference(&src, 2, 1, true), "{p} {q}"); + // Grey, and a mixed pair, along a row (2x1) and along a column (1x2). + for src in [[p, p, p, 255, q, q, q, 255], [p, q, p ^ q, 255, q, p, q ^ 0x5a, 255]] { + assert_eq!(pass(&src, 2, 1, true, &weights), reference(&src, 2, 1, true), "{p} {q}"); + assert_eq!(pass(&src, 1, 2, false, &weights), reference(&src, 1, 2, false), "{p} {q}"); + } } } } @@ -208,6 +211,13 @@ mod tests { { assert_eq!(level(v), v.round() as u8, "{v}"); } + // Values a hair either side of every half, where a wrong rounding would show. + for k in 0..255 { + let half = f64::from(k) + 0.5; + for v in [half, f64::from_bits(half.to_bits() - 1), f64::from_bits(half.to_bits() + 1)] { + assert_eq!(level(v), v.round() as u8, "{v}"); + } + } for i in 0..=255 * 4096u32 { let v = f64::from(i) / 4096.0; assert_eq!(level(v), v.round() as u8, "{v}");