test(app): RTL and collapsed-rail captures; curve keyboard insertion tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+70
-1
No files matched your search
@@ -73,6 +73,32 @@ public sealed class CurveMathTests
|
||||
Assert.False(CurveMath.CanRemove(3, 2, pinEnds: true));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KeyboardInsertionUsesThePlayheadWhenAPointFitsThere()
|
||||
{
|
||||
double[] xs = [0, 0.4, 1];
|
||||
Assert.Approximately(0.7, CurveMath.KeyboardInsertionX(xs, 1, 0.7, Gap, pinEnds: true), 0);
|
||||
// On a point, past a pinned end or unset: the middle of the gap after the selection (before it for the last point).
|
||||
Assert.Approximately(0.7, CurveMath.KeyboardInsertionX(xs, 1, 0.4, Gap, pinEnds: true), 1e-12);
|
||||
Assert.Approximately(0.2, CurveMath.KeyboardInsertionX(xs, 0, double.NaN, Gap, pinEnds: true), 1e-12);
|
||||
Assert.Approximately(0.7, CurveMath.KeyboardInsertionX(xs, 2, double.NaN, Gap, pinEnds: true), 1e-12);
|
||||
Assert.Approximately(0.2, CurveMath.KeyboardInsertionX(xs, -1, double.NaN, Gap, pinEnds: true), 1e-12);
|
||||
Assert.Approximately(0.5, CurveMath.KeyboardInsertionX([], -1, double.NaN, Gap, pinEnds: false), 0);
|
||||
Assert.Approximately(0.6, CurveMath.KeyboardInsertionX([0.2], 0, double.NaN, Gap, pinEnds: false), 1e-12);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InterpolationFollowsTheSegmentsAndIsFlatBeyondTheEnds()
|
||||
{
|
||||
double[] xs = [0.2, 0.6, 1];
|
||||
double[] ys = [0.1, 0.5, 0.3];
|
||||
Assert.Approximately(0.3, CurveMath.Interpolate(xs, ys, 0.4), 1e-12);
|
||||
Assert.Approximately(0.4, CurveMath.Interpolate(xs, ys, 0.8), 1e-12);
|
||||
Assert.Approximately(0.1, CurveMath.Interpolate(xs, ys, 0), 0);
|
||||
Assert.Approximately(0.3, CurveMath.Interpolate(xs, ys, 1), 0);
|
||||
Assert.Approximately(0.25, CurveMath.Interpolate([], [], 0.25), 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HitTestPicksTheNearestPointWithinRadius()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user