Skip to content

refactor(tests): extract fixed_point_u12x4_u16x16.cpp (re-target of #3142) - #3162

Merged
zackees merged 1 commit into
masterfrom
feat/3130-fixed-point-u12x4-u16x16-extract
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3130-fixed-point-u12x4-u16x16-extract

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Re-opening of #3142. Part of #3130.

Summary by CodeRabbit

Tests

  • Expanded test coverage for fixed-point arithmetic types with new test scenarios for u8x24 and u24x8 formats.
  • Added comprehensive testing for u12x4 and u16x16 fixed-point types covering construction, arithmetic operations, comparisons, and mathematical functions.
  • Enhanced edge case and precision validation for fixed-point math operations.

…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]>
@zackees
zackees merged commit 7f1eb64 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: ac30be95-8bf3-4017-83b4-9df931c5675e

📥 Commits

Reviewing files that changed from the base of the PR and between 8b9f734 and ab4462d.

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

📝 Walkthrough

Walkthrough

The u12x4 and u16x16 unsigned fixed-point test suites are extracted from tests/fl/math/fixed_point.cpp into a new dedicated file tests/fl/math/fixed_point_u12x4_u16x16.cpp. The removed block in fixed_point.cpp is replaced with u8x24 and u24x8 test coverage.

Changes

Fixed-Point Test File Reorganization

Layer / File(s) Summary
Remove u12x4/u16x16, add u8x24/u24x8 in fixed_point.cpp
tests/fl/math/fixed_point.cpp
Tail section drops 912 lines of former u12x4/u16x16 unsigned tests and introduces u8x24 and u24x8 test sections (construction, arithmetic, shifts, comparisons, math functions, edge cases).
New file setup and full u12x4 test suite
tests/fl/math/fixed_point_u12x4_u16x16.cpp
New translation unit with FL headers, anonymous namespace, raw_t alias, and a comprehensive u12x4 test suite: construction, arithmetic (scalar/compound), shifts, comparisons, math/interpolation, advanced math (sqrt/rsqrt/pow), edge cases, and precision/rounding assertions.
u16x16 scaffolding, construction, and core arithmetic
tests/fl/math/fixed_point_u12x4_u16x16.cpp
Adds tolerance helpers (tol, sqrt_tol, pow_tol, smooth_tol, rt_tol) and check_near overloads, then tests u16x16 construction and core arithmetic (add/sub, fixed-point mul/div) with approximate comparisons.
u16x16 scalar ops, shifts, comparisons, to_float, sqrt/rsqrt
tests/fl/math/fixed_point_u12x4_u16x16.cpp
Covers scalar multiply commutativity, fractional shift behavior, comparisons, mixed arithmetic round-trips, to_float correctness, and sqrt/rsqrt math operations.
u16x16 pow, floor/ceil/fract, min/max/mod, lerp/clamp/step/smoothstep, edge values
tests/fl/math/fixed_point_u12x4_u16x16.cpp
Completes u16x16 with pow, identity checks, floor/ceil, fract, min/max/mod, lerp/clamp/step/smoothstep, unsigned range constraints, and fractional precision edge cases; closes namespace and FL_TEST_FILE registration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2972: The u8x24/u24x8 pow edge assertions in the updated fixed_point.cpp target the same pow near-1.0 boundary logic that PR #2972 introduced (snapping inputs near 1.0 to exact 1).

Poem

🐇 Hop, hop, refactor day!
Old tests split and sent away,
u12x4 gets its own new home,
u16x16 no longer needs to roam.
Fresh files bloom in the warren bright —
Every fixed-point test in sight! 🌼

✨ 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-u12x4-u16x16-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant