Repository navigation
fix(fl::ftoa): pad trailing zeros at precision=2; fix substr heap-promote test data - #2971
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughFixes float formatting to always produce the requested fractional digits and correctly sign negative values that round to zero; extends a substring test input to force heap promotion; and updates the esp32s3 bloat baseline value. ChangesFloat formatting precision and test data corrections
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)tests/fl/stl/string.cpptests/fl/stl/string.cpp:5:10: fatal error: 'fl/stl/compiler_control.h' file not found ... [truncated 1093 characters] ... ang/install/lib/clang/18/include" 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 |
Two pre-existing failures in `bash test fl_stl_string --cpp` on master: 1. `fl::printf_detail::format_float` (the underlying impl behind `fl::ftoa` and printf's `%f`) was emitting "0.0"/"1.0" for `precision=2` calls on integer-valued floats. The legacy pad-zero loop terminated at `temp_multiplier > 1`, dropping the final zero, and the digit-emission branch was guarded by `frac_part > 0`, suppressing all fractional output when zero. Replaced with a clean exact-`precision`-digit emitter that computes each digit positionally so "0.0f" -> "0.00", "1.0f" -> "1.00", "-1.5f" -> "-1.50", and small negatives like "-0.05f" preserve their sign even when the integer part rounds to zero. 2. Test "substr/substring on heap-promoted string (>64 chars)" used a 64-char literal — exactly `FASTLED_STR_INLINED_SIZE` — so the string stayed inline and `FL_CHECK_GT(s.size(), 64)` fired. Extended the literal to 66 chars to actually heap- promote. Together these unblock the `unit tests linux` CI gate that was failing on every PR branched from master after #2961/#2962. Closes #2970 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…a rewrite) format_float in src/fl/stl/stdio.h grew by ~121 B after the rewrite to honor the precision/pad argument. Update the baseline so the bloat- regression gate passes. Net regression is small and one-time (the gate exists to catch ongoing drift, not intentional fixes).
793c73d to
55cc80f
Compare
Closes #2970
Summary
Two pre-existing failures in
bash test fl_stl_string --cpponmasterthat have been blocking theunit tests linuxCI gate on every PR branched from master after #2961/#2962.Fix 1 —
fl::ftoa/printf_detail::format_floatdrops trailing zerostests/fl/stl/string.cpp:5018("fl::string - append float and double") expected"0.00"/"1.00"froms.append(0.0f)/s.append(1.0f)(the append path callsfl::ftoa(val, buf, 2)), but the underlyingfl::printf_detail::format_float(value, precision)insrc/fl/stl/stdio.hwas returning"0.0"/"1.0".Root cause:
temp_multiplier > 1, dropping the last zero digit.if (frac_part > 0), so all fractional digits were suppressed when the value was integer-valued.Replaced the post-fact pad-and-emit logic with a clean positional emitter that always writes exactly
precisionfractional digits. Verified against0.0f/1.0f/-1.5f(test cases),3.14159f@3(precision-override subcase), and-0.05f(sign preservation when integer part rounds to zero).Fix 2 — substr test data was exactly 64 chars
tests/fl/stl/string.cpp:6225("substr/substring on heap-promoted string (>64 chars)") used a 64-char literal — exactlyFASTLED_STR_INLINED_SIZE— so the string stayed inline andFL_CHECK_GT(s.size(), 64)failed. Extended the literal to 66 chars (..._XYZW) so it actually heap-promotes; thesubstr(2, 4) == "CDEF"subcase is unaffected since only the suffix changed.Why this unblocks CI
The
unit tests linuxjob has been failing on every PR for these two pre-existing test failures unrelated to the PR's own changes. Landing this fixes the gate for everyone.Test plan
bash test fl_stl_string --cpp— passes (1/1, both prior failing subcases now green)bash lint --cpp— clean (no new violations; only the pre-existing warn-only PlatformIO usage from ci: sweep PlatformIO build usage and add linters that enforce fbuild-only board builds #2701)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests