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

Fix tests

This commit is contained in:
Nathen 2024-02-22 13:15:41 -05:00
parent 636a708448
commit 286c7d507e
3 changed files with 41 additions and 45 deletions

View File

@ -4,8 +4,6 @@
using System; using System;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Statistics; using osu.Game.Rulesets.Osu.Statistics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -19,42 +17,13 @@ namespace osu.Game.Rulesets.Osu.Tests
[Test] [Test]
public void TestDistributedHits() public void TestDistributedHits()
{ {
var events = Enumerable.Range(0, 10) var events = Enumerable.Range(-5, 11)
.Select(t => new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(t, t))); .Select(t => new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), new HitCircle(), new Vector2(t, t)));
IBeatmap beatmap = new Beatmap();
beatmap.Difficulty.CircleSize = 0;
var aimError = new AimError(events); var aimError = new AimError(events);
Assert.IsNotNull(aimError.Value); Assert.IsNotNull(aimError.Value);
Assert.AreEqual(Math.Sqrt(57) * 10, aimError.Value!.Value); Assert.AreEqual(Math.Sqrt(20) * 10, aimError.Value!.Value, 1e-5);
}
[Test]
public void TestMissesIncreaseDeviation()
{
var eventsWithMiss = new[]
{
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, null),
new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(0, 0)),
};
var eventsWithoutMiss = new[]
{
new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Great, new HitCircle(), null, new Vector2(0, 0)),
};
IBeatmap beatmap = new Beatmap();
beatmap.Difficulty.CircleSize = 0;
var aimErrorWithMiss = new AimError(eventsWithMiss);
var aimErrorWithoutMiss = new AimError(eventsWithoutMiss);
Assert.IsTrue(aimErrorWithMiss.Value != null && aimErrorWithoutMiss.Value != null && Precision.DefinitelyBigger(aimErrorWithMiss.Value.Value, aimErrorWithoutMiss.Value.Value));
} }
[Test] [Test]
@ -62,13 +31,25 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var events = new[] var events = new[]
{ {
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, null), new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), new HitCircle(), null),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, null), new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), new HitCircle(), null),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, null), new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), new HitCircle(), null),
}; };
IBeatmap beatmap = new Beatmap(); var aimError = new AimError(events);
beatmap.Difficulty.CircleSize = 0;
Assert.IsNull(aimError.Value);
}
[Test]
public void TestNullLastObjectReturnsNull()
{
var events = new[]
{
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
};
var aimError = new AimError(events); var aimError = new AimError(events);

View File

@ -24,9 +24,9 @@ namespace osu.Game.Rulesets.Osu.Tests
new HitEvent(0, 1.0, HitResult.Great, new HitCircle { Position = new Vector2(1, -1) }, new HitCircle { Position = new Vector2(1, 1) }, new Vector2(1, 0)) new HitEvent(0, 1.0, HitResult.Great, new HitCircle { Position = new Vector2(1, -1) }, new HitCircle { Position = new Vector2(1, 1) }, new Vector2(1, 0))
}; };
var aimError = new AverageAimError(events); var averageAimError = new AverageAimError(events);
Assert.AreEqual(1, aimError.Value!.Value); Assert.AreEqual(1, averageAimError.Value!.Value);
} }
[Test] [Test]
@ -39,9 +39,24 @@ namespace osu.Game.Rulesets.Osu.Tests
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), new HitCircle(), null), new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), new HitCircle(), null),
}; };
var aimError = new AverageAimError(events); var averageAimError = new AverageAimError(events);
Assert.IsNull(aimError.Value); Assert.IsNull(averageAimError.Value);
}
[Test]
public void TestNulLastObjectReturnsNull()
{
var events = new[]
{
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
new HitEvent(0, 1.0, HitResult.Miss, new HitCircle(), null, new Vector2(0, 0)),
};
var averageAimError = new AverageAimError(events);
Assert.IsNull(averageAimError.Value);
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
foreach (var e in hitCircleEvents) foreach (var e in hitCircleEvents)
{ {
if (e.Position == null) if (e.LastHitObject == null || e.Position == null)
continue; continue;
eventCount += 1; eventCount += 1;
@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
continue; continue;
eventCount += 1; eventCount += 1;
sumOfPointVectors += CalcAngleAdjustedPoint(e) ?? new Vector2(0, 0); sumOfPointVectors += e.CalcAngleAdjustedPoint() ?? new Vector2(0, 0);
} }
if (eventCount == 0) if (eventCount == 0)