Repository navigation
Description
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:
- PR 1 (foundation): Add
tests/fl/math/fixed_point_bounds.hwith theaccuracy_bounds<T>table + helpers (named namespace). Modifyfixed_point.cppto#includeit and drop the inline definitions.bash test --cppmust stay green. This PR is the keystone — the other 7 PRs cannot land without it. - PR 2: Extract
fixed_point_constexpr.cpp(lines 811–1130). Remove fromfixed_point.cpp. Verifybash test --cppis green. - PR 3: Extract
fixed_point_bit_exact.cpp(lines 1131–1970). - PR 4: Extract
fixed_point_signed_types.cpp(lines 1971–2186). - PR 5: Extract
fixed_point_u4x12_u8x8.cpp(lines 2187–3055). - PR 6: Extract
fixed_point_u12x4_u16x16.cpp(lines 3056–3968). - PR 7: Extract
fixed_point_u8x24_u24x8.cpp(lines 3969–4817). - PR 8: Extract
fixed_point_misc.cpp(lines 4818–5230); delete the emptyfixed_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.hexists with shared bounds table. - PR 2 lands:
fixed_point_constexpr.cppextracted; original file shrinks. - PR 3 lands:
fixed_point_bit_exact.cppextracted. - PR 4 lands:
fixed_point_signed_types.cppextracted. - PR 5 lands:
fixed_point_u4x12_u8x8.cppextracted. - PR 6 lands:
fixed_point_u12x4_u16x16.cppextracted. - PR 7 lands:
fixed_point_u8x24_u24x8.cppextracted. - PR 8 lands:
fixed_point_misc.cppextracted; originalfixed_point.cppdeleted. - After all PRs, every
tests/fl/math/fixed_point*.cppis < 1,000 LOC. -
bash test --cppis green at every step. - No
FL_TEST_CASElost or renamed.
Notes
- If
fixed_point_u4x12_u8x8.cpporfixed_point_u12x4_u16x16.cppcreeps past 1,000 LOC during the actual extraction (extra blank lines, header re-includes), split them per-type. The cut points are obvious:// u4x12→// u8x8and// u12x4→// u16x16. fixed_point_bounds.hshould live undertests/(test-only header), notsrc/, unless we later decide to expose accuracy bounds in the public API.- Each new
.cppneeds the same#include "test.h"+#include "fl/math/fixed_point.h"+#include "fixed_point_bounds.h"prelude.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
refactor(tests): extract fixed_point_misc.cpp from fixed_point.cpp (p…
refactor(tests): extract fixed_point_misc.cpp from fixed_point.cpp (p…
refactor(tests): extract fixed_point_constexpr.cpp from fixed_point.c…
refactor(tests): extract fixed_point_constexpr.cpp from fixed_point.c…
refactor(tests): extract fixed_point_bounds.h shared header (part of #…
refactor(tests): extract fixed_point_bounds.h shared header (part of #…
refactor(tests): extract fixed_point_u4x12_u8x8.cpp from fixed_point.…
refactor(tests): extract fixed_point_u4x12_u8x8.cpp from fixed_point.…
refactor(tests): extract fixed_point_u12x4_u16x16.cpp from fixed_poin…
refactor(tests): extract fixed_point_u12x4_u16x16.cpp from fixed_poin…
refactor(tests): extract fixed_point_u8x24_u24x8.cpp from fixed_point…
refactor(tests): extract fixed_point_u8x24_u24x8.cpp from fixed_point…
refactor(tests): extract fixed_point_test_helpers.h shared header (pa…
refactor(tests): extract fixed_point_test_helpers.h shared header (pa…