diff --git a/tests/test_waveform_view.cpp b/tests/test_waveform_view.cpp index c47970d..df0f467 100644 --- a/tests/test_waveform_view.cpp +++ b/tests/test_waveform_view.cpp @@ -244,13 +244,13 @@ static void testResolveDragFrameClamps() { CHECK(resolveDragFrame(ov, 1000, 950, 500) == 1000); // clamp high (== frameCount) } -static void testResolveDragFrameRounds() { - // 500px area over 1000 frames -> 2 frames/px. A +3px drag -> round(6.0)=6; the rounding is - // at the frame centre. Use a scale where a fractional result appears. - const OverlayArea ov = overlayOf(Rect::ltrb(0, 0, 300, 60)); // 1000 frames / 300px = 3.33 frames/px - // +3px -> 3*1000/300 = 10.0 -> 10 frames. +static void testResolveDragFrameTruncatesAtFractionalScale() { + // 300px area over 1000 frames -> 3.33 frames/px, so frameToX(start) -> +dx -> xToFrame + // lands on the column's truncating partition rather than a whole multiple of dx. + const OverlayArea ov = overlayOf(Rect::ltrb(0, 0, 300, 60)); + // frameToX(100) = 30; xToFrame(30 + 3) = 33*1000/300 = 110.0 -> 110 frames. CHECK(resolveDragFrame(ov, 1000, 100, 3) == 110); - // +1px -> 1000/300 = 3.33 -> rounds to 3. + // frameToX(100) = 30; xToFrame(30 + 1) = 31*1000/300 = 103.33 -> truncates to 103. CHECK(resolveDragFrame(ov, 1000, 100, 1) == 103); } @@ -279,8 +279,10 @@ static void testResolveDragFrameLandsOnCursorColumn() { const std::int64_t cursorFrame = xToFrame(ov, frameCount, grabX + dx); CHECK(cursorFrame == 11); // the contract's own derivation CHECK(resolveDragFrame(ov, frameCount, startFrame, dx) == cursorFrame); - // General form, swept across both framescolumns: the resolved frame's - // OWN column (frameToX) must contain the cursor pixel the drag actually landed on. + // Structural coverage, not behavioural: this sweep asserts resolveDragFrame's own definition + // (frameToX then xToFrame) and cannot fail while it calls those two functions. Its value is + // pinning that there is no second, independent mapping hiding in some framescolumns corner — the single behavioural anchor is the literal 11 above. const std::int64_t counts[] = {5, 37, 251, 9973}; const int deltas[] = {-97, -3, -1, 1, 3, 97}; for (std::int64_t n : counts) { @@ -815,7 +817,7 @@ int main() { testResolveDragFrameShift(); testResolveDragFrameClamps(); - testResolveDragFrameRounds(); + testResolveDragFrameTruncatesAtFractionalScale(); testResolveDragFrameDegenerate(); testResolveDragFrameLandsOnCursorColumn();