Skip to content

refactor(tests): extract fixed_point_bounds.h (re-target of #3138) - #3160

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

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

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Re-opening of #3138 (closed when base branch merged). Bounds.h keystone for #3130.

Summary by CodeRabbit

  • Tests
    • Reorganized test accuracy bounds configuration for improved maintainability and code reusability.

…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]>
@zackees
zackees merged commit 158462c into master Jun 16, 2026
4 checks passed
@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: 9c22807c-3f2e-46ac-884b-c6582b4cd614

📥 Commits

Reviewing files that changed from the base of the PR and between e2ea6ef and 7b47080.

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

📝 Walkthrough

Walkthrough

accuracy_bounds<T> template specializations and their C++14 out-of-line constexpr definitions are extracted from tests/fl/math/fixed_point.cpp into a new shared header tests/fl/math/fixed_point_bounds.h. The test file is updated to #include that header instead of defining the constants inline.

Changes

Extract accuracy_bounds to shared header

Layer / File(s) Summary
New fixed_point_bounds.h with specializations and ODR definitions
tests/fl/math/fixed_point_bounds.h
Adds #pragma once header with usage documentation, six accuracy_bounds<fl::s*x*> template specializations defining static constexpr float max-error thresholds for trig/root/power/smoothstep operations, and out-of-line constexpr float definitions for every static member to satisfy C++11/C++14 ODR requirements.
fixed_point.cpp switches to #include
tests/fl/math/fixed_point.cpp
Removes the 212-line inline accuracy_bounds block and replaces it with a single #include "fixed_point_bounds.h".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 Hop, hop, the bounds break free,
No longer stuck where they shouldn't be!
A header now holds each float in place,
With out-of-line defs to win the race.
ODR compliance? A rabbit's delight —
Shared across files, everything's right! ✨

✨ 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-bounds-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.

1 participant