Skip to content

refactor(tests): extract fixed_point_test_helpers.h — fixed_point.cpp now under 1K LOC (closes #3130) (re-target of #3144) - #3164

Merged
zackees merged 1 commit into
masterfrom
feat/3130-fixed-point-test-helpers-header
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3130-fixed-point-test-helpers-header

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Re-opening of #3144. Closes #3130 — final extraction for fixed_point.cpp split.

Summary by CodeRabbit

  • Chores
    • Refactored test infrastructure for fixed-point math operations by consolidating reusable test helpers into a shared header file, improving code maintainability and reducing duplication.

…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]>
@zackees
zackees merged commit 471b203 into master Jun 16, 2026
4 checks passed
@zackees
zackees deleted the feat/3130-fixed-point-test-helpers-header branch June 16, 2026 04:43
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 46ebee59-da00-46f0-b6c4-2caee9e1e975

📥 Commits

Reviewing files that changed from the base of the PR and between 7143f60 and a678f83.

📒 Files selected for processing (2)
  • tests/fl/math/fixed_point.cpp
  • tests/fl/math/fixed_point_test_helpers.h

📝 Walkthrough

Walkthrough

Extracts all reusable fixed-point test helper code from tests/fl/math/fixed_point.cpp into a new tests/fl/math/fixed_point_test_helpers.h. The original file drops ~1031 lines of infrastructure and gains one #include, while the new header provides the full set of bit-exact, transcendental, accuracy measurement, templated measurement runners, equivalence, and regression-gate helpers.

Changes

Fixed-point test helper extraction

Layer / File(s) Summary
Bit-exact and transcendental test templates
tests/fl/math/fixed_point_test_helpers.h
New header sections (lines 1–473) define templates for construction (default/float/raw), arithmetic ops, shifts, comparisons, floor/ceil/fract/abs/sign, and transcendental test templates (sin/cos/sincos/atan/atan2/asin/acos/sqrt/rsqrt/pow/smoothstep/to_float) parameterized by external accuracy thresholds.
Accuracy measurement, equivalence, and bounds checkers
tests/fl/math/fixed_point_test_helpers.h
Defines AccuracyResult, non-templated measure_* functions for each transcendental op, print_row/print_row2 reporters, templated measure_*_t<T> runners, run_type_accuracy<T>, test_bit_exact_equivalence<Tmpl,Conc>, and check_all_accuracy_bounds<T>.
Migrate fixed_point.cpp to header
tests/fl/math/fixed_point.cpp
Adds #include "fixed_point_test_helpers.h" and removes the six previously inlined helper blocks (bit-exact templates, transcendental templates, AccuracyResult/measure_* definitions, multi-type measurement runners, equivalence helper, and accuracy-bounds regression gate), retaining all concrete FL_TEST_CASE bodies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit once stuffed all its tests in one hutch,
Five thousand long lines was a bit much!
So headers were born, and helpers moved out,
Now each little file has less clutter to tout.
The warren grows tidy — hop, hop, hop, hooray! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3130-fixed-point-test-helpers-header

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.

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.

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

1 participant