lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 1ad1ea8 1/5: Elaborate a unit test


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1ad1ea8 1/5: Elaborate a unit test
Date: Mon, 2 Aug 2021 18:25:15 -0400 (EDT)

branch: master
commit 1ad1ea88a3885d73ac874e132aff8f0ba831143a
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Elaborate a unit test
---
 zero_test.cpp | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/zero_test.cpp b/zero_test.cpp
index 3220e5d..22ed1c7 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -432,10 +432,20 @@ void test_binary64_midpoint()
     LMI_TEST_EQUAL(0.0, binary64_midpoint(-3.1416,  2.718));
 
     // Do not return zero when one argument is zero and the other
-    // has an opposite signbit. Note the "UN" in "UNEQUAL" here.
-
-    LMI_TEST_UNEQUAL(0.0, binary64_midpoint( 3.1416, -0.0)); // "UN"!
-    LMI_TEST_UNEQUAL(0.0, binary64_midpoint(-3.1416,  0.0)); // "UN"!
+    // has an opposite signbit.
+
+    double const d0 = binary64_midpoint( 3.1416, -0.0);
+    double const d1 = binary64_midpoint(-3.1416,  0.0);
+    LMI_TEST_UNEQUAL(0.0, d0); // do not return zero
+    LMI_TEST_UNEQUAL(0.0, d1); // do not return zero
+    // Actual values are calculated...
+    LMI_TEST(materially_equal( 1.91739e-154, d0, 1.0e-5));
+    LMI_TEST(materially_equal(-1.91739e-154, d1, 1.0e-5));
+    // ...as though the zero's signbit matched the other argument's:
+    double const e0 = binary64_midpoint( 3.1416,  0.0);
+    double const e1 = binary64_midpoint(-3.1416, -0.0);
+    LMI_TEST_EQUAL(d0, e0);
+    LMI_TEST_EQUAL(d1, e1);
 
     // One argument zero, the other nonzero:  binary midpoint, i.e.,
     //   std::midpoint(*(std::uint64_t)(&x), *(std::uint64_t)(&y))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]