1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-15 12:42:48 +08:00
Files
osu-lazer/osu.Game.Tests/NonVisual/FormatUtilsTest.cs
T
Bartłomiej Dach 4fd2a488b7 Floor star rating to 2 decimal places rather than rounding
Rounding semi-regularly confuses users who aim for star rating pass / FC
medals and then feel they have been cheated out of a medal because they
passed an "X-star beatmap", but the actual star rating of the beatmap is
slightly under X.

The latest instance of this can be found at
https://osu.ppy.sh/community/forums/topics/2091333?n=2. The relevant
beatmap there is https://osu.ppy.sh/beatmapsets/2162554#osu/4746232,
whose raw star rating is 6.9976070253117344.

The other direction would be to fix the star rating medals instead, but
I think this is more reasonable given we already do similar things to
accuracy displays.
2025-06-13 09:11:06 +02:00

39 lines
1.2 KiB
C#

// 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.
using NUnit.Framework;
using osu.Game.Utils;
namespace osu.Game.Tests.NonVisual
{
[TestFixture]
public class FormatUtilsTest
{
[TestCase(0, "0.00%")]
[TestCase(0.01, "1.00%")]
[TestCase(0.9899, "98.99%")]
[TestCase(0.989999, "98.99%")]
[TestCase(0.99, "99.00%")]
[TestCase(0.9999, "99.99%")]
[TestCase(0.999999, "99.99%")]
[TestCase(1, "100.00%")]
public void TestAccuracyFormatting(double input, string expectedOutput)
{
Assert.AreEqual(expectedOutput, input.FormatAccuracy().ToString());
}
[TestCase(3, "3.00")]
[TestCase(3.3, "3.30")]
[TestCase(3.55, "3.55")]
[TestCase(3.553, "3.55")]
[TestCase(3.557, "3.55")]
[TestCase(3.9999, "3.99")]
[TestCase(3.999999, "3.99")]
[TestCase(4, "4.00")]
public void TestStarRatingFormatting(double input, string expectedOutput)
{
Assert.AreEqual(expectedOutput, input.FormatStarRating().ToString());
}
}
}