From 555559c5c12010122798086b6419b51442b86ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 14 Dec 2023 20:41:07 +0100 Subject: [PATCH] Add testing for `GetRateAdjustedDisplayDifficulty()` implementations --- .../CatchRateAdjustedDisplayDifficultyTest.cs | 52 +++++++++++++++ .../OsuRateAdjustedDisplayDifficultyTest.cs | 65 +++++++++++++++++++ .../TaikoRateAdjustedDisplayDifficultyTest.cs | 52 +++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 osu.Game.Rulesets.Catch.Tests/CatchRateAdjustedDisplayDifficultyTest.cs create mode 100644 osu.Game.Rulesets.Osu.Tests/OsuRateAdjustedDisplayDifficultyTest.cs create mode 100644 osu.Game.Rulesets.Taiko.Tests/TaikoRateAdjustedDisplayDifficultyTest.cs diff --git a/osu.Game.Rulesets.Catch.Tests/CatchRateAdjustedDisplayDifficultyTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchRateAdjustedDisplayDifficultyTest.cs new file mode 100644 index 0000000000..f77ec64df3 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/CatchRateAdjustedDisplayDifficultyTest.cs @@ -0,0 +1,52 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using NUnit.Framework; +using osu.Game.Beatmaps; + +namespace osu.Game.Rulesets.Catch.Tests +{ + [TestFixture] + public class CatchRateAdjustedDisplayDifficultyTest + { + private static IEnumerable difficultyValuesToTest() + { + for (float i = 0; i <= 10; i += 0.5f) + yield return i; + } + + [TestCaseSource(nameof(difficultyValuesToTest))] + public void TestApproachRateIsUnchangedWithRateEqualToOne(float originalApproachRate) + { + var ruleset = new CatchRuleset(); + var difficulty = new BeatmapDifficulty { ApproachRate = originalApproachRate }; + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(originalApproachRate)); + } + + [Test] + public void TestRateBelowOne() + { + var ruleset = new CatchRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(1.67).Within(0.01)); + } + + [Test] + public void TestRateAboveOne() + { + var ruleset = new CatchRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(7.67).Within(0.01)); + } + } +} diff --git a/osu.Game.Rulesets.Osu.Tests/OsuRateAdjustedDisplayDifficultyTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuRateAdjustedDisplayDifficultyTest.cs new file mode 100644 index 0000000000..aa903205c8 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/OsuRateAdjustedDisplayDifficultyTest.cs @@ -0,0 +1,65 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using NUnit.Framework; +using osu.Game.Beatmaps; + +namespace osu.Game.Rulesets.Osu.Tests +{ + [TestFixture] + public class OsuRateAdjustedDisplayDifficultyTest + { + private static IEnumerable difficultyValuesToTest() + { + for (float i = 0; i <= 10; i += 0.5f) + yield return i; + } + + [TestCaseSource(nameof(difficultyValuesToTest))] + public void TestApproachRateIsUnchangedWithRateEqualToOne(float originalApproachRate) + { + var ruleset = new OsuRuleset(); + var difficulty = new BeatmapDifficulty { ApproachRate = originalApproachRate }; + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(originalApproachRate)); + } + + [TestCaseSource(nameof(difficultyValuesToTest))] + public void TestOverallDifficultyIsUnchangedWithRateEqualToOne(float originalOverallDifficulty) + { + var ruleset = new OsuRuleset(); + var difficulty = new BeatmapDifficulty { OverallDifficulty = originalOverallDifficulty }; + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); + + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(originalOverallDifficulty)); + } + + [Test] + public void TestRateBelowOne() + { + var ruleset = new OsuRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(1.67).Within(0.01)); + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(2.22).Within(0.01)); + } + + [Test] + public void TestRateAboveOne() + { + var ruleset = new OsuRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); + + Assert.That(adjustedDifficulty.ApproachRate, Is.EqualTo(7.67).Within(0.01)); + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(7.77).Within(0.01)); + } + } +} diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoRateAdjustedDisplayDifficultyTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoRateAdjustedDisplayDifficultyTest.cs new file mode 100644 index 0000000000..4ab3f502ad --- /dev/null +++ b/osu.Game.Rulesets.Taiko.Tests/TaikoRateAdjustedDisplayDifficultyTest.cs @@ -0,0 +1,52 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using NUnit.Framework; +using osu.Game.Beatmaps; + +namespace osu.Game.Rulesets.Taiko.Tests +{ + [TestFixture] + public class TaikoRateAdjustedDisplayDifficultyTest + { + private static IEnumerable difficultyValuesToTest() + { + for (float i = 0; i <= 10; i += 0.5f) + yield return i; + } + + [TestCaseSource(nameof(difficultyValuesToTest))] + public void TestOverallDifficultyIsUnchangedWithRateEqualToOne(float originalOverallDifficulty) + { + var ruleset = new TaikoRuleset(); + var difficulty = new BeatmapDifficulty { OverallDifficulty = originalOverallDifficulty }; + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1); + + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(originalOverallDifficulty)); + } + + [Test] + public void TestRateBelowOne() + { + var ruleset = new TaikoRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 0.75); + + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(1.11).Within(0.01)); + } + + [Test] + public void TestRateAboveOne() + { + var ruleset = new TaikoRuleset(); + var difficulty = new BeatmapDifficulty(); + + var adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(difficulty, 1.5); + + Assert.That(adjustedDifficulty.OverallDifficulty, Is.EqualTo(8.89).Within(0.01)); + } + } +}