Skip to content

test(telemetry-contracts): pin float-edge and derived-trait behaviour#511

Draft
EffortlessSteven wants to merge 1 commit into
mainfrom
claude/improve-code-coverage-xaNsj-telemetry-contracts
Draft

test(telemetry-contracts): pin float-edge and derived-trait behaviour#511
EffortlessSteven wants to merge 1 commit into
mainfrom
claude/improve-code-coverage-xaNsj-telemetry-contracts

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

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_fraction float corners
    • redline = 0.0, rpm > 0+inf clamps to 1.0
    • redline = 0.0, rpm = 0.0NaN (0/0) propagates through clamp
    • redline < 0.0 → negative ratio clamps to 0.0
    • redline = +inf → ratio yields 0.0
    • redline = NaN → ratio is NaN
  • with_ffb_scalar(NaN) — stays Some(NaN); pins that f32::clamp propagates NaN and we don't filter it.
  • NEG_INFINITY rejectionwith_speed_ms, with_rpm, and with_slip_ratio all reject f32::NEG_INFINITY.
  • with_gear extremesi8::MIN and i8::MAX are stored verbatim (documented no-clamp contract).
  • has_active_flags independence from green_flag — even with green_flag=false, a yellow_flag=true still reports active.
  • TelemetryValue cross-variant inequalityBoolean(true) != Integer(1), Float(0.0) != Boolean(false), etc.
  • IEEE NaN semanticsTelemetryValue::Float(NaN) != Float(NaN) (derived PartialEq inherits IEEE).
  • TelemetryFieldCoverage and FlagCoverage derivesClone and Debug are now visibly exercised so dropping a derive is caught.
  • NormalizedTelemetry::default() direct call — equals new().
  • Large finite speeds1000 m/s converts to ~3600 km/h and ~2237 mph within f32 precision.
  • TelemetryFrame::clone and Debug — every field preserved, type name in debug.

Verification

cargo test -p racing-wheel-telemetry-contracts
running 65/39/17/21/0 → 142 tests pass

cargo clippy -p racing-wheel-telemetry-contracts --tests is clean.

Test plan

  • cargo test -p racing-wheel-telemetry-contracts
  • cargo clippy -p racing-wheel-telemetry-contracts --tests
  • Coverage CI confirms a bump for the crate

https://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh


Generated by Claude Code

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.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 15 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ad33754-ffa4-428b-88bc-435dbd36f6f7

📥 Commits

Reviewing files that changed from the base of the PR and between d151081 and 0a78931.

📒 Files selected for processing (1)
  • crates/telemetry-contracts/tests/coverage_gaps.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/improve-code-coverage-xaNsj-telemetry-contracts

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.

@github-actions

Copy link
Copy Markdown

Compatibility Layer Usage Report

Current usage count: 193
Baseline usage count: 193
ℹ️ Usage unchanged

📈 Usage Trend (Last 30 Days)

  • Peak usage: 193
  • Current trend: insufficient_data (0%)
  • Projected removal: unknown

Usage Details

  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/compat_impl.rs:69 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/linux.rs:1253 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/linux.rs:1282 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/hid/mod.rs:230 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:290 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:742 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/engine/src/protocol.rs:749 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/service_example.rs:189 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/service_example.rs:218 - temp_c
  • /home/runner/work/OpenRacing/OpenRacing/crates/schemas/src/integration_test.rs:79 - temp_c

... and 183 more occurrences

Migration Guide

To migrate these usages, replace:

  • .temp_c().temperature_c
  • .faults().fault_flags
  • .wheel_angle_mdeg().wheel_angle_deg
  • .wheel_speed_mrad_s().wheel_speed_rad_s

See Migration Patterns for detailed examples.

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.

2 participants