Skip to content

Commit

Permalink
Updated the tests according to new logic
Browse files Browse the repository at this point in the history
and fixed one minor CI code quality thing
  • Loading branch information
Givikap120 committed Jun 18, 2024
1 parent ec2b8f3 commit 1ddfc8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
45 changes: 13 additions & 32 deletions osu.Game.Tests/NonVisual/TestSceneTimedDifficultyCalculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace osu.Game.Tests.NonVisual
public class TestSceneTimedDifficultyCalculation
{
[Test]
public void TestAttributesGeneratedForAllNonSkippedObjects()
public void TestAttributesGeneratedForEachObjectOnce()
{
var beatmap = new Beatmap<TestHitObject>
{
Expand All @@ -40,15 +40,14 @@ public void TestAttributesGeneratedForAllNonSkippedObjects()

List<TimedDifficultyAttributes> attribs = new TestDifficultyCalculator(new TestWorkingBeatmap(beatmap)).CalculateTimed();

Assert.That(attribs.Count, Is.EqualTo(4));
Assert.That(attribs.Count, Is.EqualTo(3));
assertEquals(attribs[0], beatmap.HitObjects[0]);
assertEquals(attribs[1], beatmap.HitObjects[0], beatmap.HitObjects[1]);
assertEquals(attribs[2], beatmap.HitObjects[0], beatmap.HitObjects[1]); // From the nested object.
assertEquals(attribs[3], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
assertEquals(attribs[2], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
}

[Test]
public void TestAttributesNotGeneratedForSkippedObjects()
public void TestAttributesGeneratedForSkippedObjects()
{
var beatmap = new Beatmap<TestHitObject>
{
Expand All @@ -72,35 +71,14 @@ public void TestAttributesNotGeneratedForSkippedObjects()

List<TimedDifficultyAttributes> attribs = new TestDifficultyCalculator(new TestWorkingBeatmap(beatmap)).CalculateTimed();

Assert.That(attribs.Count, Is.EqualTo(1));
assertEquals(attribs[0], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
}

[Test]
public void TestNestedObjectOnlyAddsParentOnce()
{
var beatmap = new Beatmap<TestHitObject>
{
HitObjects =
{
new TestHitObject
{
StartTime = 1,
Skip = true,
Nested = 2
},
}
};

List<TimedDifficultyAttributes> attribs = new TestDifficultyCalculator(new TestWorkingBeatmap(beatmap)).CalculateTimed();

Assert.That(attribs.Count, Is.EqualTo(2));
Assert.That(attribs.Count, Is.EqualTo(3));
assertEquals(attribs[0], beatmap.HitObjects[0]);
assertEquals(attribs[1], beatmap.HitObjects[0]);
assertEquals(attribs[1], beatmap.HitObjects[0], beatmap.HitObjects[1]);
assertEquals(attribs[2], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
}

[Test]
public void TestSkippedLastObjectAddedInLastIteration()
public void TestAttributesGeneratedOnceForSkippedObjects()
{
var beatmap = new Beatmap<TestHitObject>
{
Expand All @@ -110,6 +88,7 @@ public void TestSkippedLastObjectAddedInLastIteration()
new TestHitObject
{
StartTime = 2,
Nested = 5,
Skip = true
},
new TestHitObject
Expand All @@ -122,8 +101,10 @@ public void TestSkippedLastObjectAddedInLastIteration()

List<TimedDifficultyAttributes> attribs = new TestDifficultyCalculator(new TestWorkingBeatmap(beatmap)).CalculateTimed();

Assert.That(attribs.Count, Is.EqualTo(1));
assertEquals(attribs[0], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
Assert.That(attribs.Count, Is.EqualTo(3));
assertEquals(attribs[0], beatmap.HitObjects[0]);
assertEquals(attribs[1], beatmap.HitObjects[0], beatmap.HitObjects[1]);
assertEquals(attribs[2], beatmap.HitObjects[0], beatmap.HitObjects[1], beatmap.HitObjects[2]);
}

private void assertEquals(TimedDifficultyAttributes attribs, params HitObject[] expected)
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public List<TimedDifficultyAttributes> CalculateTimed([NotNull] IEnumerable<Mod>
cancellationToken.ThrowIfCancellationRequested();
skill.Process(difficultyObjects[currentIndex]);
}

currentIndex++;
}

Expand Down

0 comments on commit 1ddfc8f

Please sign in to comment.