diff options
author | Eric Mellino <erme@microsoft.com> | 2017-07-05 22:53:12 +0300 |
---|---|---|
committer | Eric Mellino <erme@microsoft.com> | 2017-07-05 22:53:12 +0300 |
commit | 2aa74bc48a860f5bb4f0fbf10ebdf209b9d242c4 (patch) | |
tree | c9550af4a5e973564cb4c785074f5394582d054c /src/System.Numerics.Vectors | |
parent | 37683d92d1f9edd7ef36660fa8ed1952524cc177 (diff) |
Simplify infinity checks in GenericVectorTests.
Diffstat (limited to 'src/System.Numerics.Vectors')
-rw-r--r-- | src/System.Numerics.Vectors/tests/GenericVectorTests.cs | 18 | ||||
-rw-r--r-- | src/System.Numerics.Vectors/tests/GenericVectorTests.tt | 18 |
2 files changed, 12 insertions, 24 deletions
diff --git a/src/System.Numerics.Vectors/tests/GenericVectorTests.cs b/src/System.Numerics.Vectors/tests/GenericVectorTests.cs index d421b69501..de437f87b4 100644 --- a/src/System.Numerics.Vectors/tests/GenericVectorTests.cs +++ b/src/System.Numerics.Vectors/tests/GenericVectorTests.cs @@ -2642,14 +2642,11 @@ namespace System.Numerics.Tests { return double.IsNaN(d2); } - if (double.IsInfinity(d1)) + if (double.IsInfinity(d1) || double.IsInfinity(d2)) { - return AreSameInfinity(d1, d2 * 10); - } - if (double.IsInfinity(d2)) - { - return AreSameInfinity(d1 * 10, d2); + return AreSameInfinity(d1, d2); } + double diffRatio = (d1 - d2) / d1; diffRatio *= Math.Pow(10, precision); return Math.Abs(diffRatio) < 1; @@ -2661,14 +2658,11 @@ namespace System.Numerics.Tests { return float.IsNaN(f2); } - if (float.IsInfinity(f1)) + if (float.IsInfinity(f1) || float.IsInfinity(f2)) { - return AreSameInfinity(f1, f2 * 10); - } - if (float.IsInfinity(f2)) - { - return AreSameInfinity(f1 * 10, f2); + return AreSameInfinity(f1, f2); } + float diffRatio = (f1 - f2) / f1; diffRatio *= MathF.Pow(10, precision); return Math.Abs(diffRatio) < 1; diff --git a/src/System.Numerics.Vectors/tests/GenericVectorTests.tt b/src/System.Numerics.Vectors/tests/GenericVectorTests.tt index b50c989993..65863072b7 100644 --- a/src/System.Numerics.Vectors/tests/GenericVectorTests.tt +++ b/src/System.Numerics.Vectors/tests/GenericVectorTests.tt @@ -1735,14 +1735,11 @@ namespace System.Numerics.Tests { return double.IsNaN(d2); } - if (double.IsInfinity(d1)) + if (double.IsInfinity(d1) || double.IsInfinity(d2)) { - return AreSameInfinity(d1, d2 * 10); - } - if (double.IsInfinity(d2)) - { - return AreSameInfinity(d1 * 10, d2); + return AreSameInfinity(d1, d2); } + double diffRatio = (d1 - d2) / d1; diffRatio *= Math.Pow(10, precision); return Math.Abs(diffRatio) < 1; @@ -1754,14 +1751,11 @@ namespace System.Numerics.Tests { return float.IsNaN(f2); } - if (float.IsInfinity(f1)) + if (float.IsInfinity(f1) || float.IsInfinity(f2)) { - return AreSameInfinity(f1, f2 * 10); - } - if (float.IsInfinity(f2)) - { - return AreSameInfinity(f1 * 10, f2); + return AreSameInfinity(f1, f2); } + float diffRatio = (f1 - f2) / f1; diffRatio *= MathF.Pow(10, precision); return Math.Abs(diffRatio) < 1; |