1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add a basic NaN control point test for LegacyBeatmapDecoder

This commit is contained in:
Khang 2022-08-24 02:53:55 -04:00
parent c9f364d6a0
commit c7d4c739aa
2 changed files with 42 additions and 0 deletions

View File

@ -919,5 +919,32 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero)); Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero));
} }
} }
[Test]
public void TestNaNControlPoints()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("nan-control-points.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(1));
Assert.That(controlPoints.DifficultyPoints.Count, Is.EqualTo(3));
Assert.That(controlPoints.TimingPointAt(1000).BeatLength, Is.EqualTo(500));
Assert.That(controlPoints.DifficultyPointAt(1000).SliderVelocity, Is.EqualTo(1));
Assert.That(controlPoints.DifficultyPointAt(2000).SliderVelocity, Is.EqualTo(1));
Assert.That(controlPoints.DifficultyPointAt(3000).SliderVelocity, Is.EqualTo(1));
#pragma warning disable 618
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(1000)).GenerateTicks, Is.True);
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(2000)).GenerateTicks, Is.False);
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(3000)).GenerateTicks, Is.True);
#pragma warning restore 618
}
}
} }
} }

View File

@ -0,0 +1,15 @@
osu file format v14
[TimingPoints]
// NaN bpm (should be rejected)
0,NaN,4,2,0,100,1,0
// 120 bpm
1000,500,4,2,0,100,1,0
// NaN slider velocity
2000,NaN,4,3,0,100,0,1
// 1.0x slider velocity
3000,-100,4,3,0,100,0,1