public void TestRandomConvertToSliderPath() { var rng = new Random(1); var path = new JuiceStreamPath(); var sliderPath = new SliderPath(); for (int iteration = 0; iteration < 10000; iteration++) { path.Clear(); do { double time = rng.NextDouble() * 1e3; float x = (float)(rng.NextDouble() * 1e3); path.Add(time, x); } while (rng.Next(5) != 0); float sliderStartY = (float)(rng.NextDouble() * JuiceStreamPath.OSU_PLAYFIELD_HEIGHT); double requiredVelocity = path.ComputeRequiredVelocity(); double velocity = Math.Clamp(requiredVelocity, 1, 100); path.ConvertToSliderPath(sliderPath, sliderStartY, velocity); foreach (var point in sliderPath.ControlPoints) { Assert.That(point.Type, Is.EqualTo(PathType.Linear).Or.Null); Assert.That(sliderStartY + point.Position.Y, Is.InRange(0, JuiceStreamPath.OSU_PLAYFIELD_HEIGHT)); } Assert.That(sliderPath.ControlPoints[0].Position.X, Is.EqualTo(path.Vertices[0].X)); // The path is preserved only if required velocity is used. if (velocity < requiredVelocity) { continue; } Assert.That(sliderPath.Distance / velocity, Is.EqualTo(path.Duration).Within(1e-3)); for (int i = 0; i < 10; i++) { double time = rng.NextDouble() * path.Duration; float expected = path.PositionAtTime(time); Assert.That(sliderPath.PositionAt(time * velocity / sliderPath.Distance).X, Is.EqualTo(expected).Within(3e-3)); } } }