mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 19:54:15 +08:00
a996261304
It's been a while. Notes: - `SharpCompress` usages changed a bit. Manually adjusted these, mostly just renames or adjusted parameters. - nUnit 3 -> 4 migrated using https://gist.github.com/peppy/07994386d793a117350cb5f24b156585. there's a mode in this script to update to the newer `Assert.That` syntax but it requires fixes and couldn't really be bothered. - DeepEqual nuked as the only usage was on a disabled test. The reason it's disabled has been merged upstream, but it's failing for other (realm) reasons which I don't think is worthwhile to investigate for now. - This bumps Moq. I think the author is back in a sensible headspace and the new version has the stupid shit removed, so probably okay? Nice to be on a level playing field with packages for once in a long time. - Automapper is silly, but we've discussed this elsewhere. - `TestRealmKeyBindingStore` failures are a wildcard, but fixed by using a more standardised testing method. Dunno why, don't care. --------- Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
40 lines
1.2 KiB
C#
40 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 NUnit.Framework.Legacy;
|
|
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)
|
|
{
|
|
ClassicAssert.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)
|
|
{
|
|
ClassicAssert.AreEqual(expectedOutput, input.FormatStarRating().ToString());
|
|
}
|
|
}
|
|
}
|