mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Update test to only compare HitObject
s
This commit is contained in:
@ -66,6 +66,47 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.IsTrue(areComboColoursEqual(decodedAfterEncode.beatmapSkin.Configuration, decoded.beatmapSkin.Configuration));
|
Assert.IsTrue(areComboColoursEqual(decodedAfterEncode.beatmapSkin.Configuration, decoded.beatmapSkin.Configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCaseSource(nameof(allBeatmaps))]
|
||||||
|
public void TestEncodeDecodeStabilityWithNonLegacyControlPoints(string name)
|
||||||
|
{
|
||||||
|
var decoded = decodeFromLegacy(beatmaps_resource_store.GetStream(name), name);
|
||||||
|
|
||||||
|
// we are testing that the transfer of relevant data to hitobjects (from legacy control points) sticks through encode/decode.
|
||||||
|
// before the encode step, the legacy information is removed here.
|
||||||
|
decoded.beatmap.ControlPointInfo = removeLegacyControlPointTypes(decoded.beatmap.ControlPointInfo);
|
||||||
|
|
||||||
|
var decodedAfterEncode = decodeFromLegacy(encodeToLegacy(decoded), name);
|
||||||
|
|
||||||
|
// in this process, we may lose some detail in the control points section.
|
||||||
|
// let's focus on only the hitobjects.
|
||||||
|
var originalHitObjects = decoded.beatmap.HitObjects.Serialize();
|
||||||
|
var newHitObjects = decodedAfterEncode.beatmap.HitObjects.Serialize();
|
||||||
|
|
||||||
|
Assert.That(newHitObjects, Is.EqualTo(originalHitObjects));
|
||||||
|
|
||||||
|
ControlPointInfo removeLegacyControlPointTypes(ControlPointInfo controlPointInfo)
|
||||||
|
{
|
||||||
|
// emulate non-legacy control points by cloning the non-legacy portion.
|
||||||
|
// the assertion is that the encoder can recreate this losslessly from hitobject data.
|
||||||
|
Assert.IsInstanceOf<LegacyControlPointInfo>(controlPointInfo);
|
||||||
|
|
||||||
|
var newControlPoints = new ControlPointInfo();
|
||||||
|
|
||||||
|
foreach (var point in controlPointInfo.AllControlPoints)
|
||||||
|
{
|
||||||
|
// completely ignore "legacy" types, which have been moved to HitObjects.
|
||||||
|
// even though these would mostly be ignored by the Add call, they will still be available in groups,
|
||||||
|
// which isn't what we want to be testing here.
|
||||||
|
if (point is SampleControlPoint)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
newControlPoints.Add(point.Time, point.DeepClone());
|
||||||
|
}
|
||||||
|
|
||||||
|
return newControlPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestEncodeMultiSegmentSliderWithFloatingPointError()
|
public void TestEncodeMultiSegmentSliderWithFloatingPointError()
|
||||||
{
|
{
|
||||||
@ -93,37 +134,6 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.That(decodedSlider.Path.ControlPoints.Count, Is.EqualTo(5));
|
Assert.That(decodedSlider.Path.ControlPoints.Count, Is.EqualTo(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCaseSource(nameof(allBeatmaps))]
|
|
||||||
public void TestEncodeDecodeStabilityWithNonLegacyControlPoints(string name)
|
|
||||||
{
|
|
||||||
var decoded = decodeFromLegacy(beatmaps_resource_store.GetStream(name), name);
|
|
||||||
|
|
||||||
sort(decoded.beatmap);
|
|
||||||
|
|
||||||
var originalSerialized = decoded.beatmap.Serialize();
|
|
||||||
var encoded = encodeToLegacy(decoded);
|
|
||||||
|
|
||||||
Assert.AreEqual(typeof(LegacyControlPointInfo), decoded.beatmap.ControlPointInfo.GetType());
|
|
||||||
|
|
||||||
// emulate non-legacy control points by cloning the non-legacy portion.
|
|
||||||
// the assertion is that the encoder can recreate this losslessly from hitobject data.
|
|
||||||
var controlPointInfo = new ControlPointInfo();
|
|
||||||
|
|
||||||
foreach (var point in decoded.beatmap.ControlPointInfo.AllControlPoints)
|
|
||||||
controlPointInfo.Add(point.Time, point.DeepClone());
|
|
||||||
|
|
||||||
decoded.beatmap.ControlPointInfo = controlPointInfo;
|
|
||||||
|
|
||||||
Assert.AreNotEqual(typeof(LegacyControlPointInfo), decoded.beatmap.ControlPointInfo.GetType());
|
|
||||||
|
|
||||||
var decodedAfterEncode = decodeFromLegacy(encoded, name);
|
|
||||||
|
|
||||||
sort(decodedAfterEncode.beatmap);
|
|
||||||
|
|
||||||
Assert.That(decodedAfterEncode.beatmap.Serialize(), Is.EqualTo(originalSerialized));
|
|
||||||
Assert.IsTrue(areComboColoursEqual(decodedAfterEncode.beatmapSkin.Configuration, decoded.beatmapSkin.Configuration));
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool areComboColoursEqual(IHasComboColours a, IHasComboColours b)
|
private bool areComboColoursEqual(IHasComboColours a, IHasComboColours b)
|
||||||
{
|
{
|
||||||
// equal to null, no need to SequenceEqual
|
// equal to null, no need to SequenceEqual
|
||||||
|
Reference in New Issue
Block a user