mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Fix testing relying on control point order
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -9,6 +10,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Serialization;
|
using osu.Game.IO.Serialization;
|
||||||
@ -30,10 +32,22 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var decoded = decode(name, out var encoded);
|
var decoded = decode(name, out var encoded);
|
||||||
|
|
||||||
Assert.That(decoded.HitObjects.Count, Is.EqualTo(encoded.HitObjects.Count));
|
sort(decoded);
|
||||||
|
sort(encoded);
|
||||||
|
|
||||||
Assert.That(encoded.Serialize(), Is.EqualTo(decoded.Serialize()));
|
Assert.That(encoded.Serialize(), Is.EqualTo(decoded.Serialize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sort(IBeatmap beatmap)
|
||||||
|
{
|
||||||
|
// Sort control points to ensure a sane ordering, as they may be parsed in different orders. This works because each group contains only uniquely-typed control points.
|
||||||
|
foreach (var g in beatmap.ControlPointInfo.Groups)
|
||||||
|
{
|
||||||
|
ArrayList.Adapter((IList)g.ControlPoints).Sort(
|
||||||
|
Comparer<ControlPoint>.Create((c1, c2) => string.Compare(c1.GetType().ToString(), c2.GetType().ToString(), StringComparison.Ordinal)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IBeatmap decode(string filename, out IBeatmap encoded)
|
private IBeatmap decode(string filename, out IBeatmap encoded)
|
||||||
{
|
{
|
||||||
using (var stream = TestResources.GetStore().GetStream(filename))
|
using (var stream = TestResources.GetStore().GetStream(filename))
|
||||||
|
Reference in New Issue
Block a user