[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/004 2913536 06/11: Fix a unit test
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/004 2913536 06/11: Fix a unit test |
Date: |
Sun, 20 Dec 2020 17:40:09 -0500 (EST) |
branch: valyuta/004
commit 2913536e91c1b8b99e9ef9bd62155d71c3e06b4d
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
---
currency.hpp | 1 +
round_to_test.cpp | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/currency.hpp b/currency.hpp
index 00316b2..d69dd69 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -60,6 +60,7 @@ class currency
friend std::ostream& operator<<(std::ostream&, currency const&);
friend class currency_test;
template<typename T> friend class round_to;
+ friend class round_to_test;
#if defined CURRENCY_UNIT_IS_CENTS
static constexpr int cents_digits = 2;
diff --git a/round_to_test.cpp b/round_to_test.cpp
index 829d8e8..519e18f 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"
@@ -593,9 +594,10 @@ void round_to_test::test_fundamentals()
// 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."
);
- [lmi-commits] [lmi] valyuta/004 updated (3742c54 -> b73e751), Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 be42a58 03/11: Assert rather than assign, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 4a58266 09/11: Suppress the costly assertion that was recently added, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 2913536 06/11: Fix a unit test,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/004 c5f666f 08/11: Improve rounding to cents for solves, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 34326d6 04/11: Eliminate a return code that was always zero, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 abb1363 05/11: Refactor a unit test, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 7eacf2b 07/11: Prefer explicit to implicit currency rounding in unit test, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 58962eb 01/11: Refactor, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 9a03ce9 10/11: Add a handy git command, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 b73e751 11/11: Record timings as of 20201215T2247Z SHA1 3742c540, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 0c93fc2 02/11: Fix a problem somewhat mystically, Greg Chicares, 2020/12/20