lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/width-of-inf b487178 4/6: Augment unit tests


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/width-of-inf b487178 4/6: Augment unit tests
Date: Wed, 21 Mar 2018 19:20:23 -0400 (EDT)

branch: odd/width-of-inf
commit b4871789e0663343d217436edf31769c1d73bd69
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Augment unit tests
---
 miscellany_test.cpp | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index 0180e25..1da6fbb 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -27,6 +27,7 @@
 
 #include <cstdio>                       // remove()
 #include <fstream>
+#include <limits>
 
 void test_each_equal()
 {
@@ -307,10 +308,28 @@ void test_scale_power()
         ,lmi_test::what_regex("^Assertion.*failed")
         );
 
+    using D = std::numeric_limits<double>;
+    if(D::has_quiet_NaN)
+        {
+        BOOST_TEST_THROW
+            (scale_power(9, D::quiet_NaN(), D::quiet_NaN())
+            ,std::runtime_error
+            ,lmi_test::what_regex("^Assertion.*failed")
+            );
+        }
+
+    // Test positive and negative zeros.
+
     BOOST_TEST_EQUAL( 0, scale_power( 9,               0.0,               
0.0));
     BOOST_TEST_EQUAL( 0, scale_power( 9,               0.0,     
999'999'999.0));
     BOOST_TEST_EQUAL( 0, scale_power( 9,     -99'999'999.0,               
0.0));
-    BOOST_TEST_EQUAL( 0, scale_power( 9,     999'999'999.0,     
999'999'999.0));
+
+    BOOST_TEST_EQUAL( 0, scale_power( 9,              -0.0,              
-0.0));
+    BOOST_TEST_EQUAL( 0, scale_power( 9,              -0.0,     
999'999'999.0));
+    BOOST_TEST_EQUAL( 0, scale_power( 9,     -99'999'999.0,              
-0.0));
+
+    BOOST_TEST_EQUAL( 0, scale_power( 9,               0.0,              
-0.0));
+    BOOST_TEST_EQUAL( 0, scale_power( 9,              -0.0,               
0.0));
 
     // Test values for which rounding toward infinity crosses a threshold.
 



reply via email to

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