Fix eight review findings on the render-bounds diagnostics

Corrects a false comment example, fixes two tests that couldn't detect their
own regressions, adds two more read-back checkpoints around Main_OnCommand so
a drift report self-locates, guards a spurious zero-vs-zero coincidence match,
and softens two sentences that overclaimed cause or defect.
This commit is contained in:
2026-08-02 14:45:42 -04:00
parent 292d14d14c
commit 0ab4673887
6 changed files with 68 additions and 19 deletions
+21 -6
View File
@@ -278,11 +278,16 @@ static void testWindowAlreadyOnTheMillisecondGridLosesNothing() {
static void testOneFrameOfRemainderStillFloors() {
// The whole-millisecond tolerance must sit far below a frame, or it would swallow
// the very remainder this diagnostic exists to find. One frame at 48 kHz is 20.8 us
// — four orders of magnitude above the nanosecond tolerance.
// the very remainder this diagnostic exists to find. A remainder JUST BELOW a
// millisecond boundary is the discriminating case: one frame short of 1.0 s is
// 999.979166 ms, only ~0.0208 ms off the next whole millisecond. The shipped
// nanosecond tolerance still floors it down; a tolerance any wider than ~0.021 ms
// would snap it up to the millisecond instead and this test would then see 48000,
// not 47952 — which is what would fail if the tolerance regressed to something
// that wide.
const double oneFrame = 1.0 / 48000.0;
CHECK(frameCountFor(0.0, 1.0 + oneFrame, 48000) == 48001);
CHECK(msFlooredEndFrameCount(0.0, 1.0 + oneFrame, 48000) == 48000);
CHECK(frameCountFor(0.0, 1.0 - oneFrame, 48000) == 47999);
CHECK(msFlooredEndFrameCount(0.0, 1.0 - oneFrame, 48000) == 47952);
}
static void testMillisecondFloorAt44100WhereAMillisecondIsNotWholeFrames() {
@@ -333,12 +338,22 @@ static void testADriftedEndNamesBothWindowsAndBothCounts() {
static void testTheReportPrintsEnoughDigitsToShowTheDrift() {
// A report whose two numbers print identically is evidence of nothing. Two ends a
// single ULP apart — far under the sixth decimal a shorter rendering would stop at
// — must still read as two different numbers.
// — must still read as two different numbers. Pinned as the actual %.17g literals
// (not the needle the two ends share, "s)", which occurs at every precision and so
// proves nothing): a report that regressed to a shorter format like %.6g would
// print the same six significant digits for both ends, and these two `contains`
// checks would then fail.
const double asked = 4.067797;
const double stored = std::nextafter(asked, 5.0);
char askedBuf[32], storedBuf[32];
std::snprintf(askedBuf, sizeof(askedBuf), "%.17g", asked);
std::snprintf(storedBuf, sizeof(storedBuf), "%.17g", stored);
CHECK(std::string(askedBuf) != std::string(storedBuf));
const std::string s = describeBoundsDrift(0.0, asked, 0.0, stored, 48000);
CHECK(!s.empty());
CHECK(!contains(s, "4.067797s, read back [0s, 4.067797s)"));
CHECK(contains(s, askedBuf));
CHECK(contains(s, storedBuf));
}
static void testADriftedStartIsCaughtToo() {