fix(simulation): move probe tests module below Args — clippy items_after_test_module

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 22:30:10 +02:00
co-authored by Claude Fable 5
parent cf6ef2bc31
commit 5e48c85a9a
+42 -42
View File
@@ -605,48 +605,6 @@ fn encode_rgb_png(w: u32, h: u32, rgb: &[u8]) -> Vec<u8> {
out
}
#[cfg(test)]
mod tests {
use super::*;
/// The palette is indexed by `MorphologyZone` discriminant (repr(u8),
/// append-only). Pinning the LAST variant's discriminant against the
/// palette length forces a palette extension — here AND in the client
/// source of truth (`atlas_marker_overlay.gd::MORPHOLOGY_COLORS`) — when
/// a zone is appended.
#[test]
fn morphology_palette_covers_every_zone() {
assert_eq!(MorphologyZone::Wetland as usize + 1, MORPHOLOGY_RGB.len());
}
/// `true_district_of_pixel` must invert `derive_district`'s forward mapping
/// (district → fractional working-grid position via the body radius) to
/// within the half-district rounding error — ≲0.01 working pixel at
/// planetary radii.
#[test]
fn true_district_inverts_forward_mapping() {
let (w, h) = (128usize, 64usize);
let r_km = 6371.0;
let circ_m = std::f64::consts::TAU * r_km * 1000.0;
let mer_m = std::f64::consts::PI * r_km * 1000.0;
for (row, col) in [(10u16, 100u16), (32, 0), (5, 127), (63, 64)] {
let (dx, dy) = true_district_of_pixel((row, col), w, h, Some(r_km));
let px = ((dx as f64 * scale::DISTRICT_M as f64) / circ_m).rem_euclid(1.0) * w as f64;
let py = (0.5 + ((dy as f64 * scale::DISTRICT_M as f64) / mer_m).clamp(-0.5, 0.5))
* (h - 1) as f64;
assert!((px - col as f64).abs() < 0.05, "px {px} vs col {col}");
assert!((py - row as f64).abs() < 0.05, "py {py} vs row {row}");
}
}
/// Without a radius the fallback maps pixel → district 1:1 (mirrors
/// `derive_district`'s tiny-test-body branch).
#[test]
fn true_district_fallback_is_identity() {
assert_eq!(true_district_of_pixel((7, 3), 128, 64, None), (3, 7));
}
}
// ---------------------------------------------------------------------------
// Args
// ---------------------------------------------------------------------------
@@ -694,3 +652,45 @@ impl Args {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
/// The palette is indexed by `MorphologyZone` discriminant (repr(u8),
/// append-only). Pinning the LAST variant's discriminant against the
/// palette length forces a palette extension — here AND in the client
/// source of truth (`atlas_marker_overlay.gd::MORPHOLOGY_COLORS`) — when
/// a zone is appended.
#[test]
fn morphology_palette_covers_every_zone() {
assert_eq!(MorphologyZone::Wetland as usize + 1, MORPHOLOGY_RGB.len());
}
/// `true_district_of_pixel` must invert `derive_district`'s forward mapping
/// (district → fractional working-grid position via the body radius) to
/// within the half-district rounding error — ≲0.01 working pixel at
/// planetary radii.
#[test]
fn true_district_inverts_forward_mapping() {
let (w, h) = (128usize, 64usize);
let r_km = 6371.0;
let circ_m = std::f64::consts::TAU * r_km * 1000.0;
let mer_m = std::f64::consts::PI * r_km * 1000.0;
for (row, col) in [(10u16, 100u16), (32, 0), (5, 127), (63, 64)] {
let (dx, dy) = true_district_of_pixel((row, col), w, h, Some(r_km));
let px = ((dx as f64 * scale::DISTRICT_M as f64) / circ_m).rem_euclid(1.0) * w as f64;
let py = (0.5 + ((dy as f64 * scale::DISTRICT_M as f64) / mer_m).clamp(-0.5, 0.5))
* (h - 1) as f64;
assert!((px - col as f64).abs() < 0.05, "px {px} vs col {col}");
assert!((py - row as f64).abs() < 0.05, "py {py} vs row {row}");
}
}
/// Without a radius the fallback maps pixel → district 1:1 (mirrors
/// `derive_district`'s tiny-test-body branch).
#[test]
fn true_district_fallback_is_identity() {
assert_eq!(true_district_of_pixel((7, 3), 128, 64, None), (3, 7));
}
}