test(pidff-common): cover padding bytes and parser boundaries#509
test(pidff-common): cover padding bytes and parser boundaries#509EffortlessSteven wants to merge 1 commit into
Conversation
Adds 21 tests that pin previously uncovered behavior in the shared PIDFF encoder/parser crate: - Set Effect padding (bytes 5-8, trigger marker at 10, trailing 13) is now asserted to be zero across both a unit test and a 256-case proptest, so a future encoder change cannot silently shift the layout. - Device Gain byte 1 is pinned to zero, the clamp boundary is asserted at both 10000 and 10001, and the report-id byte is asserted on every device-control flag combination. - BlockLoadReport, EffectType, EffectOp, and BlockLoadStatus now have Debug/Clone/PartialEq coverage so derived traits don't silently regress. - parse_block_load gains tests for 4-byte (rejected), oversized (accepted), all status bytes 4..=255 (rejected), and an empty-buffer case, plus a proptest that pins the relationship between the first byte and parse success. - Adds an "encoder length matches LEN constant" sanity check across every public encoder.
|
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 21 new tests for
openracing-pidff-common, pinning behaviour that the existing suite did not exercise.The crate sits in the HID device protocol layer — every Moza, Simucube, AccuForce, FFBeast, etc. crate re-uses its encoders — so a regression that, for example, shifted a padding byte would propagate silently to every vendor. These tests turn the layout into an executable contract.
What the new tests cover
0xFFno-trigger-button marker), and byte 13 are now pinned to expected values in both a unit test and a 256-case proptest.0,127,200,255.DURATION_INFINITEproduces0xFF, 0xFFat byte positions 3 and 4, not just theu16view.buf[1]must stay0; covered by both a direct test and a proptest over allu16values.10000(kept) and10001(clamped).buf[0] == DEVICE_CONTROL.BlockLoadReport,EffectType,EffectOp,BlockLoadStatusall getClone,Eq/Ne, andDebug-format assertions, so removing a derive cannot pass CI.parse_block_loadboundary cases — 4-byte (rejected), oversized 8-byte (accepted),status ∈ 4..=255(rejected, brute-forced), and empty buffer.*_LENconstants — sanity check on every public encoder.PID_POOLconstant — pinned to0x13even though no encoder uses it yet.Verification
cargo clippy -p openracing-pidff-common --testsis clean.Test plan
cargo test -p openracing-pidff-commoncargo clippy -p openracing-pidff-common --testsopenracing-pidff-commonhttps://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh
Generated by Claude Code