mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 02:52:54 +08:00
Merge pull request #10449 from smoogipoo/ensure-conversion-stability
Ensure stable sorting order in beatmap conversion tests
This commit is contained in:
commit
da03084251
@ -83,11 +83,17 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
RandomZ = snapshot.RandomZ;
|
RandomZ = snapshot.RandomZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void PostProcess()
|
||||||
|
{
|
||||||
|
base.PostProcess();
|
||||||
|
Objects.Sort();
|
||||||
|
}
|
||||||
|
|
||||||
public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ;
|
public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ;
|
||||||
public override bool Equals(ConvertMapping<ConvertValue> other) => base.Equals(other) && Equals(other as ManiaConvertMapping);
|
public override bool Equals(ConvertMapping<ConvertValue> other) => base.Equals(other) && Equals(other as ManiaConvertMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ConvertValue : IEquatable<ConvertValue>
|
public struct ConvertValue : IEquatable<ConvertValue>, IComparable<ConvertValue>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A sane value to account for osu!stable using ints everwhere.
|
/// A sane value to account for osu!stable using ints everwhere.
|
||||||
@ -102,5 +108,15 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
||||||
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
||||||
&& Column == other.Column;
|
&& Column == other.Column;
|
||||||
|
|
||||||
|
public int CompareTo(ConvertValue other)
|
||||||
|
{
|
||||||
|
var result = StartTime.CompareTo(other.StartTime);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
return Column.CompareTo(other.Column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,12 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
var ourResult = convert(name, mods.Select(m => (Mod)Activator.CreateInstance(m)).ToArray());
|
var ourResult = convert(name, mods.Select(m => (Mod)Activator.CreateInstance(m)).ToArray());
|
||||||
var expectedResult = read(name);
|
var expectedResult = read(name);
|
||||||
|
|
||||||
|
foreach (var m in ourResult.Mappings)
|
||||||
|
m.PostProcess();
|
||||||
|
|
||||||
|
foreach (var m in expectedResult.Mappings)
|
||||||
|
m.PostProcess();
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
int mappingCounter = 0;
|
int mappingCounter = 0;
|
||||||
@ -239,6 +245,13 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
set => Objects = value;
|
set => Objects = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked after this <see cref="ConvertMapping{TConvertValue}"/> is populated to post-process the contained data.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void PostProcess()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool Equals(ConvertMapping<TConvertValue> other) => StartTime == other?.StartTime;
|
public virtual bool Equals(ConvertMapping<TConvertValue> other) => StartTime == other?.StartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user