tests: disc Key::Device redaction, locate_ranges ordering/cap, forced-probe truncation verdict

This commit is contained in:
Matthew Jackson
2026-09-29 20:35:31 -07:00
parent 6eaf59950a
commit 7b6767b3bc
2 changed files with 50 additions and 0 deletions
+30
View File
@@ -4155,6 +4155,12 @@ mod tests {
assert!(d.contains("redacted"), "AacsState missing marker: {d}");
for k in [
Key::Device(vec![crate::aacs::types::DeviceKey {
key: [0xD5; 16],
node: 0,
uv: 0,
u_mask_shift: 0,
}]),
Key::Unit(vec![(1, [0xD5; 16])]),
Key::Volume([0xD5; 16]),
Key::Processing(vec![[0xD5; 16]]),
@@ -7097,6 +7103,30 @@ mod tests {
);
}
// Many ranges: sorted largest-first, capped at 50 with the overflow counted.
// Input is ascending, so a flipped sort keeps the smallest and reports its gap.
// bps = 2048 B/s, so range i (i+1 sectors) lasts (i+1) * 1000 ms.
#[test]
fn locate_ranges_sorts_largest_first_and_truncates_at_fifty() {
let mut title = title_with_size(204_800, vec![]);
title.duration_secs = 100.0;
let raw: Vec<(u64, u64)> = (0..53u64)
.map(|i| (i * 100 * 2048, (i + 1) * 2048))
.collect();
let r = locate_ranges(&raw, &title);
assert_eq!(r.num_ranges, 53);
assert_eq!(r.truncated, 3);
assert_eq!(r.ranges.len(), 50);
assert_eq!(r.largest_gap_ms, 53_000.0);
assert_eq!(r.ranges[0].count, 53);
assert_eq!(r.ranges[49].count, 4, "the three smallest were dropped");
assert!(
r.ranges
.windows(2)
.all(|w| w[0].duration_ms > w[1].duration_ms)
);
}
// bps computed exactly 0.0: duration_ms/main_at_risk_ms must stay 0.0,
// never inf/NaN. Kills `bps > 0.0` flipped to `>=` at both sites (the
// boundary exactly zero would wrongly take the division branch).
+20
View File
@@ -2114,6 +2114,26 @@ mod tests {
}
}
// A truncated run may still assert "not forced" (positive evidence: a non-forced set was
// seen) when the shape gate allows demotion, but never a forced verdict (an absence claim).
#[test]
fn a_truncated_run_asserts_only_a_demotable_not_forced_verdict() {
let full = TrackEvidence {
observed: true,
non_forced: true,
displays: 20,
..Default::default()
};
let flagged = TrackEvidence {
observed: true,
forced_seen: true,
displays: 20,
..Default::default()
};
let ev = HashMap::from([(0x1200u16, full), (0x1201u16, flagged)]);
assert_eq!(verdicts(&ev, false), HashMap::from([(0x1200u16, false)]));
}
// Coverage is what makes a memo replayable: an entry from a thin sample must not answer a
// question needing a thorough one.
#[test]