mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
* Fix atmos UI inconsistent culture usage * Remove the need to pass localization manager (cherry picked from commit 3d911a64c7789f1e1de0df94dd27a4f0fdf05dcf)
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using Content.Shared.Localizations;
|
|
using NUnit.Framework;
|
|
|
|
namespace Content.Tests.Shared.Localizations
|
|
{
|
|
[TestFixture]
|
|
public sealed class UserInputParserTest
|
|
{
|
|
[Test]
|
|
[TestCase("1234.56", 1234.56f, true)]
|
|
[TestCase("1234,56", 1234.56f, true)]
|
|
[TestCase(" +1234.56 ", 1234.56f, true)]
|
|
[TestCase(" -1234.56 ", -1234.56f, true)]
|
|
[TestCase("1234.56e7", 0f, false)]
|
|
[TestCase("1,234.56", 0f, false)]
|
|
[TestCase("1 234,56", 0f, false)]
|
|
public void TryFloatTest(string input, float expectedOutput, bool expectedResult)
|
|
{
|
|
var result = UserInputParser.TryFloat(input, out var output);
|
|
|
|
Assert.That(result, Is.EqualTo(expectedResult));
|
|
Assert.That(output, Is.EqualTo(expectedOutput).Within(float.Epsilon));
|
|
}
|
|
|
|
[Test]
|
|
[TestCase("1234.56", 1234.56d, true)]
|
|
[TestCase("1234,56", 1234.56d, true)]
|
|
[TestCase(" +1234.56 ", 1234.56d, true)]
|
|
[TestCase(" -1234.56 ", -1234.56d, true)]
|
|
[TestCase("1234.56e7", 0d, false)]
|
|
[TestCase("1,234.56", 0d, false)]
|
|
[TestCase("1 234,56", 0d, false)]
|
|
public void TryDoubleTest(string input, double expectedOutput, bool expectedResult)
|
|
{
|
|
var result = UserInputParser.TryDouble(input, out var output);
|
|
|
|
Assert.That(result, Is.EqualTo(expectedResult));
|
|
Assert.That(output, Is.EqualTo(expectedOutput).Within(double.Epsilon));
|
|
}
|
|
}
|
|
}
|