[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()
- [lmi-commits] [lmi] master updated (a111350 -> 9d991b0), Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 6d719d2 10/15: Refactor an assertion, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 2084088 09/15: Record speed measurements, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master da240e8 03/15: Eliminate a return code that was always zero, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master d280c59 05/15: Fix a unit test,
Greg Chicares <=
- [lmi-commits] [lmi] master 7b51fab 07/15: Adapt to currency class, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master f7a1129 08/15: Store policy fees as currency, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 2666c48 06/15: Test rounding double to currency, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 5ed8f75 04/15: Refactor a unit test, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 6a6ebe3 11/15: Adapt to currency class, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 1d5c923 01/15: Change some internal names, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 1e5d1ea 12/15: Adapt to currency class, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 27bd748 13/15: Write $0.00 as a currency rather than floating-point constant, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 9d991b0 15/15: Round currency as such, Greg Chicares, 2021/01/25
- [lmi-commits] [lmi] master 306ba4e 02/15: Introduce optional (for now) currency class, Greg Chicares, 2021/01/25