Skip to content

Split tests/fl/math/fixed_point.cpp (5,230 LOC) into 8 files of <1K LOC each (sub-issue of #3127) #3130

Closed

Description

@zackees

Tracked by #3127.

Goal

Split tests/fl/math/fixed_point.cpp (5,230 LOC, 170 kB) into 8 files of <1K LOC each plus one shared private header. Each new file gets its own FL_TEST_FILE(FL_FILEPATH).

Split table

New file Content Source range (current line nums) Approx LOC
tests/fl/math/fixed_point_bounds.h accuracy_bounds<T> specializations + measurement helpers (no tests) 104–810 ~705
tests/fl/math/fixed_point_constexpr.cpp constexpr raw / from_raw / arithmetic / math / value verification 811–1130 ~320
tests/fl/math/fixed_point_bit_exact.cpp Bit-exact + Transcendental tests + accuracy reports 1131–1970 ~840
tests/fl/math/fixed_point_signed_types.cpp signed fixed_point<> bit-exact + accuracy bounds (s4x12, s8x8, s12x4, s8x24, s16x16, s24x8) + GitHub-#2174 regression 1971–2186 ~210
tests/fl/math/fixed_point_u4x12_u8x8.cpp u4x12 + u8x8 type-specific tests 2187–3055 ~870
tests/fl/math/fixed_point_u12x4_u16x16.cpp u12x4 + u16x16 type-specific tests 3056–3968 ~915
tests/fl/math/fixed_point_u8x24_u24x8.cpp u8x24 + u24x8 type-specific tests 3969–4817 ~850
tests/fl/math/fixed_point_misc.cpp scalar alignment, constexpr scalar ops, integer ctor, pow boundary (#2969) 4818–5230 ~410

After the split, the original fixed_point.cpp is deleted (or shrinks to a thin file that does nothing — preferably deleted).

Approach

The namespace { ... } anonymous block currently spanning the entire file must be replaced with a named helper namespace (e.g., fl::test::fp_detail) in the shared fixed_point_bounds.h, so the bounds table can be shared across the 8 test TUs without duplicate-symbol errors. Each test file then includes fixed_point_bounds.h and pulls in only what it needs.

PR plan

Strongly recommended order so each PR has a clean "before == green, after == green" property:

  1. PR 1 (foundation): Add tests/fl/math/fixed_point_bounds.h with the accuracy_bounds<T> table + helpers (named namespace). Modify fixed_point.cpp to #include it and drop the inline definitions. bash test --cpp must stay green. This PR is the keystone — the other 7 PRs cannot land without it.
  2. PR 2: Extract fixed_point_constexpr.cpp (lines 811–1130). Remove from fixed_point.cpp. Verify bash test --cpp is green.
  3. PR 3: Extract fixed_point_bit_exact.cpp (lines 1131–1970).
  4. PR 4: Extract fixed_point_signed_types.cpp (lines 1971–2186).
  5. PR 5: Extract fixed_point_u4x12_u8x8.cpp (lines 2187–3055).
  6. PR 6: Extract fixed_point_u12x4_u16x16.cpp (lines 3056–3968).
  7. PR 7: Extract fixed_point_u8x24_u24x8.cpp (lines 3969–4817).
  8. PR 8: Extract fixed_point_misc.cpp (lines 4818–5230); delete the empty fixed_point.cpp.

Each PR uses the Closes #<this-issue> pattern only on PR 8 (the final cleanup). PRs 1-7 reference this issue but do not close it.

Acceptance criteria

  • PR 1 lands: fixed_point_bounds.h exists with shared bounds table.
  • PR 2 lands: fixed_point_constexpr.cpp extracted; original file shrinks.
  • PR 3 lands: fixed_point_bit_exact.cpp extracted.
  • PR 4 lands: fixed_point_signed_types.cpp extracted.
  • PR 5 lands: fixed_point_u4x12_u8x8.cpp extracted.
  • PR 6 lands: fixed_point_u12x4_u16x16.cpp extracted.
  • PR 7 lands: fixed_point_u8x24_u24x8.cpp extracted.
  • PR 8 lands: fixed_point_misc.cpp extracted; original fixed_point.cpp deleted.
  • After all PRs, every tests/fl/math/fixed_point*.cpp is < 1,000 LOC.
  • bash test --cpp is green at every step.
  • No FL_TEST_CASE lost or renamed.

Notes

  • If fixed_point_u4x12_u8x8.cpp or fixed_point_u12x4_u16x16.cpp creeps past 1,000 LOC during the actual extraction (extra blank lines, header re-includes), split them per-type. The cut points are obvious: // u4x12 → // u8x8 and // u12x4 → // u16x16.
  • fixed_point_bounds.h should live under tests/ (test-only header), not src/, unless we later decide to expose accuracy bounds in the public API.
  • Each new .cpp needs the same #include "test.h" + #include "fl/math/fixed_point.h" + #include "fixed_point_bounds.h" prelude.

Activity

  1. added
    type: feature
    priority: medium
    area: ci
    on Jun 16, 2026
  2. moved this from Triage to Done in FastLED Trackeron Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cipriority: mediumtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions