MidpointRounding
This commit is contained in:
@@ -46,7 +46,7 @@ namespace Content.Tests.Shared.Chemistry
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("1.005", "1")]
|
||||
[TestCase("1.005", "1.01")]
|
||||
[TestCase("0.999", "1")]
|
||||
public void ReagentUnitStringTests(string value, string expected)
|
||||
{
|
||||
@@ -57,6 +57,7 @@ namespace Content.Tests.Shared.Chemistry
|
||||
[Test]
|
||||
[TestCase(1.001f, 1.001f, "2")]
|
||||
[TestCase(1.001f, 1.004f, "2")]
|
||||
[TestCase(1f, 1.005f, "2.01")]
|
||||
[TestCase(1f, 2.005f, "3.01")]
|
||||
public void CalculusPlus(float aFloat, float bFloat, string expected)
|
||||
{
|
||||
@@ -111,11 +112,11 @@ namespace Content.Tests.Shared.Chemistry
|
||||
|
||||
[Test]
|
||||
[TestCase(0.995f, 100)]
|
||||
[TestCase(1.005f, 100)]
|
||||
[TestCase(1.005f, 101)]
|
||||
[TestCase(2.005f, 201)]
|
||||
public void FloatRoundingTest(float a, int expected)
|
||||
{
|
||||
var result = (int) Math.Round(a * (float) Math.Pow(10, 2));
|
||||
var result = (int) Math.Round(a * (float) Math.Pow(10, 2), MidpointRounding.AwayFromZero);
|
||||
Assert.AreEqual(expected, result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user