diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-28 16:56:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-28 16:56:33 +0300 |
| commit | 320f9f084ec77b8543e17268ec5e2b3655f50082 (patch) | |
| tree | 2446ddf24642200907319c5c820010e2f5426ebc /tests/cli.sh | |
| parent | ec88017a6c3bb2ad16d53dccde1d9546e15d1bdf (diff) | |
Fix stats gauge bars rendering at width:0% (stats_category_max)
Regression from or0 (STATS_* accessors): stats_category_max compared
values via `(( _stats_counts_ref[key] > max ))`. For a nameref to an
ASSOCIATIVE array, an arithmetic subscript is itself arithmetic-evaluated,
so a string key (e.g. "sony") resolves to an unset variable -> 0, i.e. it
always read index 0 and returned max 0. Every bar then scaled to
width:0% (counts/percentages were unaffected, so only the bars looked
broken). Read the value through a quoted ${assoc[$key]} expansion first,
then compare.
The byte-identical double-render test missed this because both renders
were equally broken; added explicit non-zero bar-width assertions
(100% / 50%) to test_render_stats_page_renders_sections_and_escapes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/cli.sh')
| -rwxr-xr-x | tests/cli.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh index ca5d170..cc0bd1c 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -4799,6 +4799,14 @@ BASH test::assert_contains \ '<a href="camera-canon-eos-5d/index.html">Canon EOS 5D</a>' "$html" test::assert_contains '2 (67%)' "$html" + # Gauge bars scale each bucket to its section's busiest bucket: with 2 Canon + # vs 1 Nikon the camera bars are 100% and 50% wide. Regression guard: a prior + # stats_category_max bug (arithmetic subscript on an associative-array nameref + # resolving the string key to 0) returned max 0, collapsing EVERY bar to + # width:0%. Asserting the non-zero widths catches that; the byte-identical + # double-render test could not (both renders were equally broken). + test::assert_contains 'class="stats-bar-fill" style="width:100%"' "$html" + test::assert_contains 'class="stats-bar-fill" style="width:50%"' "$html" # A histogram section is present. test::assert_contains '<h2>ISO</h2>' "$html" test::assert_contains '400' "$html" |
