Skip to content

refactor(tests): extract string_comparison_hash.cpp (part of #3131) - #3149

Closed
zackees wants to merge 11 commits into
feat/3131-string-append-concat-extractfrom
feat/3131-string-comparison-hash-extract
Closed

zackees wants to merge 11 commits into
feat/3131-string-append-concat-extractfrom
feat/3131-string-comparison-hash-extract

Conversation

@zackees

@zackees zackees commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fourth extraction for #3131. Comparison + hash section (285 LOC). Stacked on #3148. PR 4 of 9 for #3131.

zackees and others added 11 commits June 15, 2026 19:35
…art of #3130, meta #3127)

First extraction in the fixed_point.cpp split (#3130). Moves the misc
section (lines 4818-5226) into its own file:
  - Fixed-point scalar type alignment tests
  - Constexpr scalar multiply/divide tests (s0x32, u0x32)
  - Integer constructor tests (PR #2197 int width portability)
  - pow boundary regression tests (#2969)

Also extends ci/hooks/check_test_file_pairing.py to allow sibling-split
test files. The original 1:1 pairing rule rejected fixed_point_misc.cpp
because there is no src/fl/math/fixed_point_misc.h. The new sibling-split
allowance walks back the base name via underscore separators and allows
the write when the longest base prefix has both an existing paired test
file and a matching src header. This unblocks the rest of #3127's splits
without weakening the convention for genuinely unpaired test files.

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 17/17 build steps).

fixed_point.cpp: 5,230 -> 4,816 LOC
fixed_point_misc.cpp (new): 440 LOC

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…pp (part of #3130)

Second extraction in #3130. Moves the constexpr validation section
(original lines 811-1129 + the constexpr_raw_check helper at 120-124)
into its own file:
  - constexpr raw() compile-time check (all 13 types)
  - constexpr from_raw compile-time check
  - constexpr arithmetic operators
  - constexpr comparisons
  - constexpr conversions
  - constexpr math functions (mod, floor, ceil, fract, abs, sign, lerp,
    clamp, step, sqrt, rsqrt)
  - constexpr value verification (concrete value computations)

Plus the 23 constexpr_*_check<T>(...) helper templates that the tests
use; they were only referenced by the moved test cases.

The original section header "Concrete Bit-Exact Tests (All Types)" now
correctly introduces the bit-exact tests that remain in fixed_point.cpp.

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.27s test time).

fixed_point.cpp: 4,816 -> 4,488 LOC
fixed_point_constexpr.cpp (new): 343 LOC

Stacked on top of feat/3130-fixed-point-misc-extract (PR #3135) because
both PRs depend on the same ci/hooks/check_test_file_pairing.py sibling-
split allowance that #3135 introduces.

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…3130)

Third extraction in #3130, the keystone for the remaining four per-type
PRs. Moves the accuracy_bounds<T> template specialization table (original
lines 126-331 = 6 specializations + their out-of-line definitions) into
a new shared header.

Include pattern: each consumer .cpp file includes fixed_point_bounds.h
from WITHIN its anonymous namespace, so each translation unit gets its
own private copy. This avoids ODR concerns with the out-of-line constexpr
static member definitions, which are still required for C++11/C++14
compatibility on this codebase.

Header uses fully-qualified fl::s4x12 etc., so it works regardless of
whether the consumer has 'using namespace fl;' in scope.

Unblocks the upcoming per-type extractions:
  - fixed_point_signed_types.cpp
  - fixed_point_u4x12_u8x8.cpp
  - fixed_point_u12x4_u16x16.cpp
  - fixed_point_u8x24_u24x8.cpp

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.28s test time,
69.5s build).

fixed_point.cpp: 4,488 -> 4,277 LOC
fixed_point_bounds.h (new): 230 LOC

Stacked on feat/3130-fixed-point-constexpr-extract (PR #3136), which is
stacked on feat/3130-fixed-point-misc-extract (PR #3135). Both
predecessors are required because they introduce the
ci/hooks/check_test_file_pairing.py sibling-split allowance.

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…cpp (part of #3130)

Fourth extraction in #3130. Moves the u4x12 + u8x8 unsigned type tests
into their own file. Both share a section because they share the
file-local approx_equal() helper (used only within these two sections).

Content moved:
  - 28 FL_TEST_CASE u4x12 tests (construction, arithmetic, math ops,
    edge cases, precision, compound operations)
  - 60+ FL_TEST_CASE u8x8 tests (construction variants, addition/sub/
    mul/div, shifts, comparisons, math ops, sqrt/rsqrt/pow, edge cases)
  - approx_equal() static helper (lines 1644-1646 of original)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.23s test time,
44s build).

fixed_point.cpp: 4,277 -> 3,404 LOC
fixed_point_u4x12_u8x8.cpp (new): 896 LOC

Stacked on feat/3130-fixed-point-bounds-header (PR #3138). Predecessors:
  - feat/3130-fixed-point-misc-extract (PR #3135 — hook + misc)
  - feat/3130-fixed-point-constexpr-extract (PR #3136 — constexpr)
  - feat/3130-fixed-point-bounds-header (PR #3138 — bounds.h)

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…t.cpp (part of #3130)

Fifth extraction in #3130. Moves the u12x4 + u16x16 unsigned type tests
into their own file. Both share a section because the section's u16x16
sub-section defines its own check_near() overloads and tol()/smooth_tol()
/rt_tol() helpers used only within these two type sections.

Content moved:
  - ~15 FL_TEST_CASE u12x4 tests (construction, addition, sub, mul, div,
    shifts, comparisons, math functions, advanced math, edge cases,
    precision)
  - ~30 FL_TEST_CASE u16x16 tests (default/float/from_raw construction,
    arithmetic, comparisons, mixed arithmetic, to_float, sqrt/rsqrt/pow,
    sqrt identity, floor/ceil/fract, min/max/mod, lerp/clamp/step/
    smoothstep, edge values, unsigned range, fractional precision)
  - tol(), smooth_tol(), rt_tol() constexpr helpers (only used in this
    section)
  - check_near(u16x16, ...) overloads (only used in this section)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.39s test time,
44.6s build).

fixed_point.cpp: 3,404 -> 2,492 LOC
fixed_point_u12x4_u16x16.cpp (new): 935 LOC

Stacked on feat/3130-fixed-point-u4x12-u8x8-extract (PR #3139).

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
….cpp (part of #3130)

Sixth extraction in #3130. Moves the u8x24 + u24x8 unsigned type tests
into their own file.

Content moved:
  - ~12 FL_TEST_CASE u8x24 tests (construction, addition, sub, mul, div,
    scalar mul, shifts, comparisons, math functions, sqrt/rsqrt/pow,
    edge cases, complex expressions)
  - ~25 FL_TEST_CASE u24x8 tests (default/float/from_raw construction,
    arithmetic, comparisons, mixed arithmetic, to_float, sqrt/rsqrt/pow,
    sqrt identity, floor/ceil/fract, abs, min/max/mod, lerp/clamp/step/
    smoothstep, edge values, large value arithmetic)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.34s test time,
56s build).

fixed_point.cpp: 2,492 -> 1,643 LOC
fixed_point_u8x24_u24x8.cpp (new): 872 LOC

Stacked on feat/3130-fixed-point-u12x4-u16x16-extract (PR #3142).

Part of #3130. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rt of #3130) — closes the loop

Seventh extraction in #3130. Moves all the test infrastructure templates
into a shared header. With this PR, fixed_point.cpp drops to 613 LOC —
under the meta 1K-LOC target. Together with PRs #3135, #3136, #3138,
#3139, #3142, #3143, the original 5,230-LOC monolith is fully decomposed.

Content moved (1053 LOC of helpers from 5 non-contiguous ranges):
  - test_*_impl<T> bit-exact helpers (original lines 131-585)
  - AccuracyResult struct + non-templated measure_* helpers + print_row
    helpers (original lines 838-1054)
  - measure_*_t<T> templated helpers + run_type_accuracy<T> (original
    lines 1120-1356)
  - test_bit_exact_equivalence<Tmpl, Conc> (original lines 1369-1430)
  - check_all_accuracy_bounds<T> regression gate (original lines
    1456-1515)

Same include pattern as fixed_point_bounds.h: each consumer .cpp file
includes from WITHIN its anonymous namespace, after bounds.h.

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.37s test time,
117s build).

fixed_point.cpp: 1,643 -> 613 LOC (under 1K target)
fixed_point_test_helpers.h (new): 1053 LOC (header, no LOC cap)

After this PR, fixed_point.cpp contains only:
  - includes + FL_TEST_FILE wrapper + namespace + raw_t + check_near +
    FP_TYPES macro + includes to bounds.h and test_helpers.h
  - Bit-exact test cases (CHECK_EQ-based)
  - Transcendental test cases (CHECK_CLOSE with bounds)
  - s16x16 accuracy report
  - multi-type accuracy report
  - fixed_point<N,M> vs sNxM bit-exact tests
  - per-type accuracy bounds tests
  - GitHub #2174 regression test
  - to_float comprehensive test

Stacked on feat/3130-fixed-point-u8x24-u24x8-extract (PR #3143).

Closes #3130 once all 7 stacked PRs merge.
Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… of #3131)

First extraction in #3131 (string.cpp split, sub-issue of #3127). Moves
the smallest section (lines 3898-4271 of original, 'Tests from
string_memory_bugs.cpp') into its own file.

Content moved (375 LOC):
  - StringHolder - Capacity off-by-one bugs
  - StringHolder - hasCapacity checks
  - StringHolder - Edge cases exposing capacity bugs
  - StringHolder - Memory safety with incorrect capacity

Tests pass: bash test fl_stl_string --cpp (1/1, 0.26s test time, 80s
build).

string.cpp: 6,468 -> 6,093 LOC
string_memory_bugs.cpp (new): 389 LOC

Stacked on feat/3130-fixed-point-test-helpers-header (PR #3144) for the
sibling-split hook update introduced in #3135.

Part of #3131. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… of #3131)

Second extraction in #3131. Moves the 'Type-erased basic_string
optimization tests' section (~195 LOC).

Content: COW safety, move semantics, inline-to-heap transition, self
operations, assignment + heap promotion, self-referential append, insert
on literal/view tests.

Tests pass: bash test fl_stl_string --cpp (1/1, 0.35s test time, 31s
build).

string.cpp: 6,093 -> 5,898 LOC
string_type_erased.cpp (new): 208 LOC

Stacked on feat/3131-string-memory-bugs-extract (PR #3146).

Part of #3131. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rt of #3131)

Third extraction in #3131. Moves the 'append + concatenation +
self-referential write' section (~307 LOC).

Tests pass: bash test fl_stl_string --cpp (1/1, 0.45s test time).

string.cpp: 5,898 -> 5,591 LOC
string_append_concat.cpp (new): 320 LOC

Stacked on feat/3131-string-type-erased-extract (PR #3147).

Part of #3131. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…part of #3131)

Fourth extraction in #3131. Comparison + hash section (~271 LOC).

Tests pass: bash test fl_stl_string --cpp (1/1, 0.61s).

string.cpp: 5,591 -> 5,320 LOC
string_comparison_hash.cpp (new): 285 LOC

Stacked on PR #3148. Part of #3131. Meta: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fce7962a-32f8-43a7-bae2-ca1b833cfa4c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3131-string-comparison-hash-extract

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 16, 2026
@zackees
zackees force-pushed the feat/3131-string-append-concat-extract branch from 5ab0620 to 22d29cc Compare June 16, 2026 04:45
@zackees
zackees deleted the branch feat/3131-string-append-concat-extract June 16, 2026 04:45
@zackees zackees closed this Jun 16, 2026
zackees added a commit that referenced this pull request Jun 16, 2026
…t of #3131)

Fifth extraction in #3131. Optimization section (~456 LOC).

Tests pass: bash test fl_stl_string --cpp (1/1, 0.58s).

string.cpp: 5,320 -> 4,864 LOC
string_optimization.cpp (new): 474 LOC

Stacked on PR #3149. Part of #3131. Meta: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 16, 2026
…t of #3131) (#3169)

Fifth extraction in #3131. Optimization section (~456 LOC).

Tests pass: bash test fl_stl_string --cpp (1/1, 0.58s).

string.cpp: 5,320 -> 4,864 LOC
string_optimization.cpp (new): 474 LOC

Stacked on PR #3149. Part of #3131. Meta: #3127.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 16, 2026
…te original (closes #3131)

Final extraction in #3131 (string.cpp split). The remaining 'str.cpp
basic ops' section (was lines 1-2283 of original, ~2257 LOC of content)
was larger than the meta's initial estimate of ~870 LOC, so this PR
splits it into THREE files instead of one, keeping each under 1K LOC:

  - string_basic_ops.cpp (693 LOC): construction, reserve, FixedVector
    interop, long strings, overflow, concat, insert, erase, replace
  - string_search_a.cpp (666 LOC): rfind, find_first_of, find_last_of
  - string_search_b.cpp (953 LOC): find_first_not_of, find_last_not_of

With these three files, the original string.cpp becomes empty (only the
FL_TEST_FILE wrapper would remain) and is deleted.

Summary of #3131 — all 11 extractions:
  PR  | New file                       | LOC
  ----+--------------------------------+-----
  #3146 | string_memory_bugs.cpp       | 389
  #3147 | string_type_erased.cpp       | 208
  #3148 | string_append_concat.cpp     | 320
  #3149 | string_comparison_hash.cpp   | 285
  #3150 | string_optimization.cpp      | 474
  #3151 | string_comprehensive.cpp     | 786
  #3153 | string_ctor_iterator.cpp     | 979
  #3154 | string_basic_b.cpp           | 864
  this  | string_basic_ops.cpp         | 693
  this  | string_search_a.cpp          | 666
  this  | string_search_b.cpp          | 953
        | original string.cpp DELETED  |

Every resulting .cpp file is under 1,000 LOC. Original 6,468 LOC monolith
fully decomposed across 11 PRs + 1 deletion.

Tests pass: bash test fl_stl_string_basic_ops --cpp (1/1).

Stacked on feat/3131-string-basic-b-extract (PR #3154).

Closes #3131 once all stacked PRs merge. Meta tracking issue: #3127.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 16, 2026
…te original (closes #3131) (#3173)

Final extraction in #3131 (string.cpp split). The remaining 'str.cpp
basic ops' section (was lines 1-2283 of original, ~2257 LOC of content)
was larger than the meta's initial estimate of ~870 LOC, so this PR
splits it into THREE files instead of one, keeping each under 1K LOC:

  - string_basic_ops.cpp (693 LOC): construction, reserve, FixedVector
    interop, long strings, overflow, concat, insert, erase, replace
  - string_search_a.cpp (666 LOC): rfind, find_first_of, find_last_of
  - string_search_b.cpp (953 LOC): find_first_not_of, find_last_not_of

With these three files, the original string.cpp becomes empty (only the
FL_TEST_FILE wrapper would remain) and is deleted.

Summary of #3131 — all 11 extractions:
  PR  | New file                       | LOC
  ----+--------------------------------+-----
  #3146 | string_memory_bugs.cpp       | 389
  #3147 | string_type_erased.cpp       | 208
  #3148 | string_append_concat.cpp     | 320
  #3149 | string_comparison_hash.cpp   | 285
  #3150 | string_optimization.cpp      | 474
  #3151 | string_comprehensive.cpp     | 786
  #3153 | string_ctor_iterator.cpp     | 979
  #3154 | string_basic_b.cpp           | 864
  this  | string_basic_ops.cpp         | 693
  this  | string_search_a.cpp          | 666
  this  | string_search_b.cpp          | 953
        | original string.cpp DELETED  |

Every resulting .cpp file is under 1,000 LOC. Original 6,468 LOC monolith
fully decomposed across 11 PRs + 1 deletion.

Tests pass: bash test fl_stl_string_basic_ops --cpp (1/1).

Stacked on feat/3131-string-basic-b-extract (PR #3154).

Closes #3131 once all stacked PRs merge. Meta tracking issue: #3127.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant