mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Add tests and fix negative expected distances
This commit is contained in:
parent
27dd12a66d
commit
2654710d91
@ -146,7 +146,41 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLengthenLastSegment()
|
||||||
|
{
|
||||||
|
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||||
|
AddStep("lengthen last segment", () => path.ExpectedDistance.Value = 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShortenLastSegment()
|
||||||
|
{
|
||||||
|
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||||
|
AddStep("shorten last segment", () => path.ExpectedDistance.Value = 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShortenFirstSegment()
|
||||||
|
{
|
||||||
|
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||||
|
AddStep("shorten first segment", () => path.ExpectedDistance.Value = 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShortenToZeroLength()
|
||||||
|
{
|
||||||
|
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||||
|
AddStep("shorten to 0 length", () => path.ExpectedDistance.Value = 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShortenToNegativeLength()
|
||||||
|
{
|
||||||
|
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||||
|
AddStep("shorten to -10 length", () => path.ExpectedDistance.Value = -10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PathControlPoint> createSegment(PathType type, params Vector2[] controlPoints)
|
private List<PathControlPoint> createSegment(PathType type, params Vector2[] controlPoints)
|
||||||
|
@ -262,6 +262,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
// The expected distance is negative or zero
|
// The expected distance is negative or zero
|
||||||
// TODO: Perhaps negative path lengths should be disallowed altogether
|
// TODO: Perhaps negative path lengths should be disallowed altogether
|
||||||
|
cumulativeLength.Add(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user