Repository navigation
fix(test): rgbww profile API — assert by-value contract, not pointer identity - #2604
Conversation
…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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test for ChangesColorimetric profile test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
fl_gfx_rgbwwwas failing on master attests/fl/gfx/rgbww.cpp:188: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_varfromsetup()). The test was never updated.If the old
after == &caller_ptrassertion were to pass now, it would mean the dangling-pointer behavior had been reintroduced.Updated to assert the by-value contract:
These assertions test what the implementation actually promises and catch a regression to the dangling-pointer behavior (
after != &customfails 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