1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 19:22:56 +08:00
osu-lazer/osu.Game.Tests/NonVisual/Ranking/UnstableRateTest.cs

79 lines
2.6 KiB
C#
Raw Normal View History

2020-08-31 20:28:45 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-08-31 20:28:45 +08:00
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Tests.NonVisual.Ranking
{
[TestFixture]
public class UnstableRateTest
{
[Test]
public void TestDistributedHits()
{
var events = Enumerable.Range(-5, 11)
2023-11-13 03:13:38 +08:00
.Select(t => new HitEvent(t - 5, 1.0, HitResult.Great, new HitObject(), null, null));
2020-08-31 20:28:45 +08:00
var unstableRate = new UnstableRate(events);
Assert.IsNotNull(unstableRate.Value);
Assert.IsTrue(Precision.AlmostEquals(unstableRate.Value.Value, 10 * Math.Sqrt(10)));
2020-08-31 20:28:45 +08:00
}
[Test]
public void TestMissesAndEmptyWindows()
{
var events = new[]
{
2023-11-13 03:13:38 +08:00
new HitEvent(-100, 1.0, HitResult.Miss, new HitObject(), null, null),
new HitEvent(0, 1.0, HitResult.Great, new HitObject(), null, null),
new HitEvent(200, 1.0, HitResult.Meh, new HitObject { HitWindows = HitWindows.Empty }, null, null),
2020-08-31 20:28:45 +08:00
};
var unstableRate = new UnstableRate(events);
Assert.AreEqual(0, unstableRate.Value);
2020-08-31 20:28:45 +08:00
}
2023-11-13 03:16:06 +08:00
[Test]
public void TestStaticRateChange()
{
var events = new[]
{
new HitEvent(-150, 1.5, HitResult.Great, new HitObject(), null, null),
new HitEvent(-150, 1.5, HitResult.Great, new HitObject(), null, null),
new HitEvent(150, 1.5, HitResult.Great, new HitObject(), null, null),
new HitEvent(150, 1.5, HitResult.Great, new HitObject(), null, null),
};
var unstableRate = new UnstableRate(events);
Assert.AreEqual(10 * 100, unstableRate.Value);
}
[Test]
public void TestDynamicRateChange()
{
var events = new[]
{
new HitEvent(-50, 0.5, HitResult.Great, new HitObject(), null, null),
new HitEvent(75, 0.75, HitResult.Great, new HitObject(), null, null),
new HitEvent(-100, 1.0, HitResult.Great, new HitObject(), null, null),
new HitEvent(125, 1.25, HitResult.Great, new HitObject(), null, null),
};
var unstableRate = new UnstableRate(events);
Assert.AreEqual(10 * 100, unstableRate.Value);
}
2020-08-31 20:28:45 +08:00
}
}