summaryrefslogtreecommitdiff
path: root/tests/src/CoreMangLib
diff options
context:
space:
mode:
authorHan Lee <han.lee@intel.com>2017-06-14 09:14:18 -0700
committerJan Vorlicek <janvorli@microsoft.com>2017-06-14 18:14:18 +0200
commit395f145ba0c220afb1d85ff8c26f34909d8ea424 (patch)
treef4b8ecac56be32975dfcda51d66f8d7960f07a56 /tests/src/CoreMangLib
parent7b051348604398af834713af786ac7d6ee3e5bc7 (diff)
downloadcoreclr-395f145ba0c220afb1d85ff8c26f34909d8ea424.tar.gz
coreclr-395f145ba0c220afb1d85ff8c26f34909d8ea424.tar.bz2
coreclr-395f145ba0c220afb1d85ff8c26f34909d8ea424.zip
Fix a COMDouble::Round() issue (#12210)
* Fix a COMDouble::Round() issue fixes https://github.com/dotnet/coreclr/issues/12137 * Add a couple tests for Math.Round(double) based on https://github.com/dotnet/coreclr/issues/12137 * Use G17 format specifier for printing double values
Diffstat (limited to 'tests/src/CoreMangLib')
-rw-r--r--tests/src/CoreMangLib/cti/system/math/mathround3.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/src/CoreMangLib/cti/system/math/mathround3.cs b/tests/src/CoreMangLib/cti/system/math/mathround3.cs
index b48766d4ff..c4b4f69318 100644
--- a/tests/src/CoreMangLib/cti/system/math/mathround3.cs
+++ b/tests/src/CoreMangLib/cti/system/math/mathround3.cs
@@ -13,6 +13,8 @@ public class MathRound3
TestLibrary.TestFramework.LogInformation("[Positive]");
retVal = PosTest1() && retVal;
retVal = PosTest2() && retVal;
+ retVal = PosTest3() && retVal;
+ retVal = PosTest4() && retVal;
retVal = NegTest1() && retVal;
@@ -91,6 +93,48 @@ public class MathRound3
return retVal;
}
+
+ public bool PosTest3()
+ {
+ bool retVal = true;
+
+ // Test based on https://github.com/dotnet/coreclr/issues/12137
+ TestLibrary.TestFramework.BeginScenario("PosTest3: Verify Round(System.double) when decimal part of arg is very close to -0.5 .");
+
+ double doubleVal = -.50000000000000011102230246251565404236316680908203;
+ double expectedVal = -1.0;
+
+ if (Math.Round(doubleVal) != expectedVal)
+ {
+ Console.WriteLine("actual value = {0:G17}", Math.Round(doubleVal));
+ Console.WriteLine("expected value = {0:G17}", expectedVal);
+ TestLibrary.TestFramework.LogError("001.1", "Return value is wrong!");
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest4()
+ {
+ bool retVal = true;
+
+ // Test based on https://github.com/dotnet/coreclr/issues/12137
+ TestLibrary.TestFramework.BeginScenario("PosTest4: Verify Round(System.double) when decimal part of arg is very close to 0.5 .");
+
+ double doubleVal = 0.50000000000000011102230246251565404236316680908203;
+ double expectedVal = 1.0;
+
+ if (Math.Round(doubleVal) != expectedVal)
+ {
+ Console.WriteLine("actual value = {0:G17}", Math.Round(doubleVal));
+ Console.WriteLine("expected value = {0:G17}", expectedVal);
+ TestLibrary.TestFramework.LogError("001.1", "Return value is wrong!");
+ retVal = false;
+ }
+
+ return retVal;
+ }
#endregion
#region Nagetive Test Cases