From d445cfdae36b03ede997cafab88187c2fc3ecd4e Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Sat, 1 Aug 2026 10:07:47 -0400 Subject: [PATCH] test: tighten waveform-collapse and knob-face rect assertions Height-3 case pins the halfSpan clamp itself (height-4 passed pre-fix too); dropped the vacuous tall-rect mirror since min() is symmetric and wide already discriminates. --- tests/test_component_geometry.cpp | 7 ++++++- tests/test_knob_deck.cpp | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_component_geometry.cpp b/tests/test_component_geometry.cpp index 4a5a5b8..14991ce 100644 --- a/tests/test_component_geometry.cpp +++ b/tests/test_component_geometry.cpp @@ -265,9 +265,14 @@ static void testDegenerateBandClampsHalfSpanToZero() { CHECK(waveformBand(0, 3).halfSpan == 0.0); CHECK(waveformBand(0, 0).halfSpan == 0.0); // A zero half-span collapses every column onto the zero line regardless of amplitude sign. - const WaveformBand b = waveformBand(10, 4); + // height 3 (not 4): pre-clamp this rawHalfSpan is -1, so this is the case that pins the + // clamp itself, not just a halfSpan-already-zero band. + const WaveformBand b = waveformBand(10, 3); const WaveformColumnSpan s = waveformColumnSpan(b, 1.0, -1.0); CHECK(s.top == b.midY && s.bottom == b.midY); + // Domain note, not a bug: waveformBand(t, 0) still has lo=t, hi=t-1 (an inverted span) even + // though halfSpan clamps to 0 — unreachable via the band allocator (draw_kit.cpp never + // divides down to a 0-height band) and harmless if it were (LICE clips a reversed 1px line). } int main() { diff --git a/tests/test_knob_deck.cpp b/tests/test_knob_deck.cpp index 23fe0d4..a43c3ec 100644 --- a/tests/test_knob_deck.cpp +++ b/tests/test_knob_deck.cpp @@ -395,12 +395,8 @@ static void testInKnobFaceUsesTheSmallerDimensionOnANonSquareRect() { CHECK(!inKnobFace(wide, cx, cy + 15)); // inside the RECT but outside the smaller-radius disc CHECK(!inKnobFace(wide, cx + 15, cy)); // same check along the wider axis - const Rect tall{0, 0, 20, 40}; // height > width: draws a 10px-radius disc, not 20px - const int tcx = tall.x + tall.width / 2; - const int tcy = tall.y + tall.height / 2; - CHECK(inKnobFace(tall, tcx, tcy)); - CHECK(!inKnobFace(tall, tcx + 15, tcy)); - CHECK(!inKnobFace(tall, tcx, tcy + 15)); + // No mirrored tall{20,40} case: min() is symmetric in its two arguments, so a tall rect + // can't discriminate width/2 from min(w,h)/2 any differently than wide already does. } static void testEmptyDeck() {