test(curves): pin LUT inspection, custom-clone, and Bezier edges#515
test(curves): pin LUT inspection, custom-clone, and Bezier edges#515EffortlessSteven wants to merge 1 commit into
Conversation
Adds 17 tests for `openracing-curves` covering paths the existing suite did not pin down, and removes a redundant `/ 1.0` operation in the logarithmic `evaluate` short-circuit (no semantic change, the equivalent `to_lut` arm already omits it). The new tests: - `CurveLut::min_value` / `max_value` on a non-monotonic (tent function) LUT, plus `is_monotonic` for strictly-decreasing and constant LUTs — the latter covers the `<` (non-decreasing) boundary in the existing implementation. - `CurveLut::table()` returns 256 entries with `[0]=0`, `[255]=1` for the linear LUT. - `BezierCurve::evaluate(t)` clamps `t < 0` and `t > 1` (regression guard: drop the clamp and the test breaks). - `BezierCurve::map` does not diverge when two interior control points share an `x` coordinate (the Newton-Raphson's `dx_dt.abs() < EPSILON` early-out is now exercised), and produces a finite output in `[0, 1]`. - `CurveType::Custom(...)::to_lut` clones the inner LUT (asserted via `PartialEq`). - `CurveType::Custom(...)::evaluate` clamps input below `0.0` and above `1.0` to the endpoint LUT values. - `CurveError::PartialEq` for both matching and differing field cases, including cross-variant inequality. - `CurveLut` `Deserialize` rejects payloads with too few or too many entries (256 only). - `CurveType::logarithmic(_)?.evaluate(0.0) == 0.0` and `evaluate(1.0) == 1.0` under strict equality (exercises the short-circuit branches). - `evaluate` matches `to_lut().lookup(_)` at the endpoints. - `BezierCurve` `Clone` / `Debug` visibly exercised. - `CurveLut::lookup(1.0)` reaches `table[255]` (high-grid clamp). Verified with `cargo test -p openracing-curves` (147 tests pass) and `cargo clippy -p openracing-curves --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 (2)
✨ 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
openracing-curvesand removes one trivial dead expression.What changed in src
curve_type.rs—evaluateforLogarithmichad(value.ln() / log_base) / 1.0. The companionto_lutarm already drops the/ 1.0. Trailing/ 1.0removed; no semantic change. Verified byevaluate_matches_to_lut_endpoints.What the new tests cover
min_value/max_valueon a tent-function LUT;is_monotonicfor strictly-decreasing and constant LUTs (the latter pins the<non-decreasing boundary).CurveLut::table()returns all 256 entries with the expected linear endpoints.evaluateclampst. Below0matchesevaluate(0.0); above1matchesevaluate(1.0).mapwith coincident-x control points. The Newton-Raphson early-out branch (dx_dt.abs() < EPSILON) is now exercised; output stays finite and in[0, 1].CurveType::Custom(...).to_lut()clones the inner LUT underPartialEqequality.CurveType::Custom(...).evaluate(_)clamps out-of-range input to endpoint LUT values.CurveError::PartialEqfor matching + differing field cases and cross-variant inequality.CurveLutDeserializerejects payloads with!= 256entries (both too-small and too-large checked).logarithmicshort-circuits to exact0.0and1.0at the endpoints (strict equality, not tolerance), and matchesto_lut().lookup(_)at the endpoints.BezierCurveClone/Debugvisibly exercised.CurveLut::lookup(1.0)reachestable[255](high-grid clamp path).Smells noticed but not addressed in this PR
CurveLut::Deserializedoes not validate NaN/Inf entries — accepted as-is, which can later produce non-finite output throughlookupand break RT-safety claims for downstream consumers. Architecturally significant; happy to follow up with a validation PR if you want a strict-finite policy.BezierCurve::mapNewton-Raphson withdx_dt ≈ 0at iteration 0 breaks immediately and returns the seedt = target_xwithout converging. The new coincident-x test confirmsmapstays in range and doesn't panic; closing the convergence gap would need a different root-finder (bisection fallback). Architecturally significant; not included here.Verification
Test plan
cargo test -p openracing-curvescargo clippy -p openracing-curves --tests -- -D warningshttps://claude.ai/code/session_01NZ5jzdE2H3bbuPuYqbjCnh
Generated by Claude Code