[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.
- [lmi-commits] [lmi] branch odd/width-of-inf created (now b7b4812), Greg Chicares, 2018/03/21
- [lmi-commits] [lmi] odd/width-of-inf b7b4812 6/6: Sketch and compare a different algorithm, Greg Chicares, 2018/03/21
- [lmi-commits] [lmi] odd/width-of-inf df8f6b0 3/6: Augment unit tests, Greg Chicares, 2018/03/21
- [lmi-commits] [lmi] odd/width-of-inf d3cb41e 2/6: Explicitly qualify std::strtof(), Greg Chicares, 2018/03/21
- [lmi-commits] [lmi] odd/width-of-inf 3eff232 5/6: Add failing test: scale by 10^2147483640 to print "inf", Greg Chicares, 2018/03/21
- [lmi-commits] [lmi] odd/width-of-inf b487178 4/6: Augment unit tests,
Greg Chicares <=
- [lmi-commits] [lmi] odd/width-of-inf 2589cea 1/6: Add digressionary-branch spells to the grimoire, Greg Chicares, 2018/03/21