test(handbrake): pin calibration semantics and load-cell tolerance#514
test(handbrake): pin calibration semantics and load-cell tolerance#514EffortlessSteven wants to merge 1 commit into
Conversation
Adds 13 tests for `openracing-handbrake` covering paths the existing suite did not exercise: - `HandbrakeCalibration::apply` reads only `min`/`max`; the public `center` field is currently a no-op for apply. Pin that contract explicitly so a future change is intentional. - `apply` on a freshly-constructed calibration (zero samples) is equivalent to `[0, MAX_ANALOG_VALUE]`. - `HandbrakeInput::normalized` with extreme inverted full-range calibration (`min=u16::MAX, max=0`) at the midpoint returns ~0.5. - `HandbrakeInput::with_calibration(9000, 1000)` stores the inverted pair verbatim (no reorder in the builder); `normalized()` still produces a value in [0, 1]. - `normalized` with `raw_value < min` of an inverted calibration returns 0 (clamped via `saturating_sub`). - `HandbrakeCapabilities::load_cell` is permissive about negative, NaN, and ±infinity loads. Pin the current contract. - `HandbrakeCapabilities::Debug` carries the type name and field names so removing a derive is caught. - `HandbrakeError::Disconnected` `Display` carries no digits. - `parse_gamepad` ignores header bytes 0 and 1 even when they are 0xFF; all-0xFF payload engages. - `HandbrakeCapabilities` `PartialEq` inequality via differing `max_load_kg`. Verified with `cargo test -p openracing-handbrake` (158 tests pass) and `cargo clippy -p openracing-handbrake --tests -- -D warnings`.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 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 |
Compatibility Layer Usage ReportCurrent usage count: 193 📈 Usage Trend (Last 30 Days)
Usage Details
... and 183 more occurrences Migration GuideTo migrate these usages, replace:
See Migration Patterns for detailed examples. |
Summary
Adds 13 new tests for
openracing-handbrakecovering paths the existing suite did not pin down. Pure additive — no production code changed.What the new tests cover
HandbrakeCalibration::applydoes not propagatecenter. Thecenterfield is currently a dangling public field;applywrites onlymin/max. The test pins that explicitly so a future change is intentional.applyafter zero samples uses constructor defaults[0, MAX_ANALOG_VALUE].normalizedwith fully inverted full-range calibration (min=u16::MAX, max=0) at the midpoint returns ~0.5 — extreme bound stress for the internal reorder branch.with_calibration(9000, 1000)stores the inverted pair verbatim (no reorder in the builder);normalized()still produces a value in[0, 1].raw_value < minwith inverted calibration returns0.0(saturating_subclamp path).HandbrakeCapabilities::load_cellpermissive tolerance — negative, NaN, +∞, -∞ loads are all accepted verbatim. Pins the current contract (callers in vendor crates that want validation know to do it at the boundary).HandbrakeCapabilities::Debugcarries the type name and field names so dropping the derive is caught by CI.HandbrakeError::DisconnectedDisplaycarries no digits — regression guard if someone accidentally adds a payload to that variant.parse_gamepadheader-byte isolation — bytes 0 and 1 do not affect output, even when both are0xFF; all-0xFFpayload engages.HandbrakeCapabilitiesPartialEqinequality via differingmax_load_kg.Smells noticed but not fixed in this PR
HandbrakeError::InvalidPosition(u16)variant is never produced by any code path in the crate; only itsDisplayis exercised in tests.HandbrakeCalibration::centeris a public field never read byapply.Both are intentional left-overs documented by the new tests; happy to follow up with a cleanup PR if you want either removed.
Verification
Test plan
cargo test -p openracing-handbrakecargo clippy -p openracing-handbrake --tests -- -D warningshttps://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh
Generated by Claude Code