Skip to content

fix(test): rgbww profile API — assert by-value contract, not pointer identity - #2604

Merged
zackees merged 1 commit into
masterfrom
fix/rgbww-test-by-value-contract
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/rgbww-test-by-value-contract

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

fl_gfx_rgbww was failing on master at tests/fl/gfx/rgbww.cpp:188:

FAIL: rgbww colorimetric profile get/set API at ../../tests/fl/gfx/rgbww.cpp:179
  ../../tests/fl/gfx/rgbww.cpp:188: after == &custom

The test was asserting pointer identity with the caller's address. PR #2580 (CodeRabbit finding A4 from #2560) deliberately changed set_/get_rgbww_colorimetric_profile() to copy by value into singleton-owned storage — fixing a real dangling-pointer bug (callers commonly pass &local_var from setup()). The test was never updated.

If the old after == &caller_ptr assertion were to pass now, it would mean the dangling-pointer behavior had been reintroduced.

Updated to assert the by-value contract:

FL_CHECK(after != nullptr);
FL_CHECK(after != &custom);              // distinct from caller's address
FL_CHECK(after != &kRgbwwDefaultProfile); // set() actually took effect
FL_CHECK_CLOSE(after->warm_path.lum_w, 0.5f, 1e-6f);

These assertions test what the implementation actually promises and catch a regression to the dangling-pointer behavior (after != &custom fails if anyone re-stashes the caller's pointer).

Test plan

  • bash test fl_gfx_rgbww --cpp — passes (was red).
  • bash test fl_gfx_rgbww --debug — passes with ASAN/UBSAN/LSAN (per Test Failure Debug Policy).

Fixes #2603

Generated with Claude Code (https://claude.com/claude-code)

Summary by CodeRabbit

  • Tests
    • Updated test assertions for the colorimetric profile API to properly validate pointer ownership behavior and ensure the returned profile is distinct from stack-allocated and constant memory addresses.

Review Change Stack

…identity

`fl_gfx_rgbww` "rgbww colorimetric profile get/set API" was failing on
master because the test asserted pointer identity:

  set_rgbww_colorimetric_profile(&custom);
  const auto* after = get_rgbww_colorimetric_profile();
  FL_CHECK(after == &custom);   // FAILS

PR #2580 (CodeRabbit finding A4 from #2560) deliberately changed
set_*/get_* to copy into singleton-owned storage and return a pointer
to that copy — never the caller's address. The change fixed a
real dangling-pointer bug (callers typically pass `&local_var` from
`setup()`, which became invalid once `setup()` returned). If the
old `after == &caller_ptr` assertion were to pass now, it would mean
the dangling-pointer behavior had been re-introduced.

Update the test to assert what the implementation actually promises:

  - `after != nullptr`              — basic sanity
  - `after != &custom`              — distinct from caller's address
  - `after != &kRgbwwDefaultProfile` — set() actually took effect
  - `after->warm_path.lum_w == 0.5f` — value flowed through correctly

The new assertions catch a regression to the dangling-pointer behavior
(any future change that returns the caller's pointer fails
`after != &custom`).

Verified:
  bash test fl_gfx_rgbww --cpp   — passes
  bash test fl_gfx_rgbww --debug — passes (ASAN/UBSAN/LSAN)

Fixes #2603
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b983585-a8ed-4116-9c0f-bb2abd410f2e

📥 Commits

Reviewing files that changed from the base of the PR and between cb7b51c and 551e9c9.

📒 Files selected for processing (1)
  • tests/fl/gfx/rgbww.cpp

📝 Walkthrough

Walkthrough

The test for rgbww colorimetric profile get/set API is updated to validate the by-value ownership contract after the implementation migration in PR #2580. The stale pointer-identity assertion is replaced with checks that the returned profile pointer is non-null, distinct from the caller's stack address, and distinct from the default profile constant.

Changes

Colorimetric profile test

Layer / File(s) Summary
Profile get/set API assertion update
tests/fl/gfx/rgbww.cpp
The test assertion at line 188 is updated to validate the by-value storage contract: the returned profile pointer must be non-null and not equal to either the caller's custom address or the default profile constant, confirming that the profile was copied into singleton state rather than stashed as a raw pointer.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A pointer once danced in the stack,
But oh, what a dangling attack!
Now by-value we store,
What wandered before—
The test celebrates bringing back. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating test assertions from pointer identity to by-value contract verification for the rgbww colorimetric profile API.
Linked Issues check ✅ Passed All coding requirements from issue #2603 are met: test assertions verify non-null pointer, distinct from caller address, different from default profile, and value correctness.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the failing test case described in issue #2603; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/rgbww-test-by-value-contract

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.

@zackees
zackees merged commit 2461b7d into master May 30, 2026
2 of 3 checks passed
@zackees
zackees deleted the fix/rgbww-test-by-value-contract branch May 30, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fl_gfx_rgbww: stale pointer-identity assertion after by-value contract migration (#2580)

1 participant