mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 06:21:22 +08:00
Merge pull request #34934 from Valerus9/fixtestdouble
Fix TestDouble failing on systems where the decimal separator isn't a dot
This commit is contained in:
@@ -46,9 +46,12 @@ namespace osu.Game.Tests.Extensions
|
||||
|
||||
[Test]
|
||||
[SetCulture("fr-FR")]
|
||||
public void TestCultureInsensitivity()
|
||||
[TestCase(0.4, true, 2, ExpectedResult = "40%")]
|
||||
[TestCase(1e-6, false, 6, ExpectedResult = "0.000001")]
|
||||
[TestCase(0.48333, true, 4, ExpectedResult = "48.33%")]
|
||||
public string TestCultureInsensitivity(double input, bool percent, int decimalDigits)
|
||||
{
|
||||
Assert.That(0.4.ToStandardFormattedString(maxDecimalDigits: 2, asPercentage: true), Is.EqualTo("40%"));
|
||||
return input.ToStandardFormattedString(decimalDigits, percent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace osu.Game.Extensions
|
||||
|
||||
string negativeSign = Math.Round(floatValue, significantDigits) < 0 ? "-" : string.Empty;
|
||||
|
||||
return FormattableString.Invariant($"{negativeSign}{Math.Abs(floatValue).ToString($"N{significantDigits}")}");
|
||||
return $"{negativeSign}{Math.Abs(floatValue).ToString($"N{significantDigits}", CultureInfo.InvariantCulture)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
get
|
||||
{
|
||||
if (!SpeedChange.IsDefault)
|
||||
yield return ("Speed change", $"{SpeedChange.Value:N2}x");
|
||||
yield return ("Speed change", FormattableString.Invariant($@"{SpeedChange.Value:N2}x"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user