test(telemetry-contracts): pin float-edge and derived-trait behaviour#511
test(telemetry-contracts): pin float-edge and derived-trait behaviour#511EffortlessSteven wants to merge 1 commit into
Conversation
Adds 17 tests for `racing-wheel-telemetry-contracts` that cover behaviour the existing suite did not assert: - `rpm_fraction` with zero, negative, infinite, and NaN redline values. Zero redline with non-zero RPM clamps to 1.0; with zero RPM, the 0/0 NaN propagates through clamp. - `with_ffb_scalar(NaN)` stays `Some(NaN)` (clamp on NaN returns NaN). - `with_speed_ms` / `with_rpm` / `with_slip_ratio` all reject `f32::NEG_INFINITY`. - `with_gear` accepts `i8::MIN` and `i8::MAX` verbatim (documented no-clamp contract). - `has_active_flags` reports true when a hazard is set even with `green_flag=false`, so a future "green gates hazards" refactor is caught. - `TelemetryValue` cross-variant pairs (Boolean vs Integer, Float vs Boolean, Integer vs String) are unequal, and `Float(NaN) != Float(NaN)` per IEEE-754. - `TelemetryFieldCoverage` and `FlagCoverage` `Clone`/`Debug` are visibly exercised so removing a derive is caught by CI. - `NormalizedTelemetry::default()` (direct) matches `NormalizedTelemetry::new()`. - Large finite speed (`1000 m/s`) converts to ~3600 km/h and ~2237 mph within f32 precision. - `TelemetryFrame::clone` preserves every field, and `Debug` carries the type name.
|
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 17 new tests for
racing-wheel-telemetry-contracts, the crate that defines the normalized telemetry data contracts. Several float edge cases and derived-trait paths were not being exercised; this PR turns them into executable contracts.What the new tests cover
rpm_fractionfloat cornersredline = 0.0,rpm > 0→+infclamps to1.0redline = 0.0,rpm = 0.0→NaN(0/0) propagates through clampredline < 0.0→ negative ratio clamps to0.0redline = +inf→ ratio yields0.0redline = NaN→ ratio isNaNwith_ffb_scalar(NaN)— staysSome(NaN); pins thatf32::clamppropagates NaN and we don't filter it.NEG_INFINITYrejection —with_speed_ms,with_rpm, andwith_slip_ratioall rejectf32::NEG_INFINITY.with_gearextremes —i8::MINandi8::MAXare stored verbatim (documented no-clamp contract).has_active_flagsindependence fromgreen_flag— even withgreen_flag=false, ayellow_flag=truestill reports active.TelemetryValuecross-variant inequality —Boolean(true) != Integer(1),Float(0.0) != Boolean(false), etc.TelemetryValue::Float(NaN) != Float(NaN)(derivedPartialEqinherits IEEE).TelemetryFieldCoverageandFlagCoveragederives —CloneandDebugare now visibly exercised so dropping a derive is caught.NormalizedTelemetry::default()direct call — equalsnew().1000 m/sconverts to ~3600 km/h and ~2237 mph within f32 precision.TelemetryFrame::cloneandDebug— every field preserved, type name in debug.Verification
cargo clippy -p racing-wheel-telemetry-contracts --testsis clean.Test plan
cargo test -p racing-wheel-telemetry-contractscargo clippy -p racing-wheel-telemetry-contracts --testshttps://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh
Generated by Claude Code