lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d280c59 05/15: Fix a unit test


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d280c59 05/15: Fix a unit test
Date: Mon, 25 Jan 2021 09:58:05 -0500 (EST)

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

    Fix a unit test
    
    Cf.:
      https://lists.nongnu.org/archive/html/lmi/2020-12/msg00006.html
---
 round_to_test.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/round_to_test.cpp b/round_to_test.cpp
index 64c4d4d..da500db 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -23,6 +23,7 @@
 
 #include "round_to.hpp"
 
+#include "currency.hpp"                 // currency::cents_digits
 #include "fenv_lmi.hpp"
 #include "miscellany.hpp"               // floating_rep()
 #include "test_tools.hpp"
@@ -583,15 +584,18 @@ void round_to_test::test_fundamentals()
     BOOST_TEST((3.14 - v1[0]) < 1e-14);
     BOOST_TEST((2.72 - v1[1]) < 1e-14);
 
+#if defined USE_CURRENCY_CLASS
     // Try to provoke division by zero in ctor-initializer.
     //
     // nonstd::power() negates a negative exponent, but negating
-    // INT_MIN constitutes UB, so use 1 + INT_MIN.
+    // INT_MIN constitutes UB, so add one, plus currency::cents_digits
+    // because of the interplay between classes currency and round_to.
     BOOST_TEST_THROW
-        (round_to<double>(1 + INT_MIN, r_to_nearest)
+        (round_to<double>(1 + currency::cents_digits + INT_MIN, r_to_nearest)
         ,std::domain_error
         ,"Invalid number of decimals."
         );
+#endif // defined USE_CURRENCY_CLASS
 }
 
 void round_to_test::test()



reply via email to

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