[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c53ea12a 11/13: Reorder some statements in a
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c53ea12a 11/13: Reorder some statements in a unit test |
Date: |
Mon, 9 May 2022 20:13:18 -0400 (EDT) |
branch: master
commit c53ea12a078a0464b737f81e197ca52a374d96a0
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Reorder some statements in a unit test
It is especially important to set precision to DECIMAL_DIG early.
The other moved statements are similarly of general utility,
rather than specific to any particular test.
---
ul_utilities_test.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/ul_utilities_test.cpp b/ul_utilities_test.cpp
index a0820094..f2767965 100644
--- a/ul_utilities_test.cpp
+++ b/ul_utilities_test.cpp
@@ -34,6 +34,15 @@
void test_max_modal_premium()
{
+ // This affects diagnostics shown when LMI_TEST_EQUAL() fails.
+ std::cout.precision(21);
+
+ // These are generally useful for testing.
+ round_to<double> const round_down(2, r_downward);
+ round_to<double> const round_near(2, r_to_nearest);
+ round_to<double> const round_not (2, r_not_at_all);
+ round_to<double> const round_up (2, r_upward);
+
// Demonstrate the reasonableness of using materially_equal(),
// with its default tolerance, in rate_times_currency().
@@ -66,11 +75,6 @@ void test_max_modal_premium()
LMI_TEST(!test_excess_precision(0.99999999999999 ));
LMI_TEST(!test_excess_precision(0.999999999999999 ));
- round_to<double> const round_down(2, r_downward);
- round_to<double> const round_near(2, r_to_nearest);
- round_to<double> const round_not (2, r_not_at_all);
- round_to<double> const round_up (2, r_upward);
-
// Elucidate an example from an actual regression test:
// 0.00000250 specified-amount load
// $250000 specified amount
@@ -103,9 +107,6 @@ void test_max_modal_premium()
double const rate {0.0123456700000001};
currency const specamt {9'876'543'21_cents};
- // This affects diagnostics shown when LMI_TEST_EQUAL() fails.
- std::cout.precision(21);
-
LMI_TEST(materially_equal(12193254.3211401, rate * specamt.cents()));
currency p01 = max_modal_premium(rate, specamt, mce_annual , round_down);
- [lmi-commits] [lmi] master a1533521 01/13: Replace a history command, (continued)
- [lmi-commits] [lmi] master a1533521 01/13: Replace a history command, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 3903eed7 03/13: Include appropriate headers, and say why they're included, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master d9c5f0d5 04/13: Use a local alias to shorten expressions, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 3d69769b 05/13: Demonstrate that a default comparison tolerance works well, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 4d7fe889 07/13: Use rate_times_currency(), Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 03ad37d7 08/13: Note an arcanum, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master a67210ec 10/13: Better explain the purpose of each block of unit tests, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master ee272a29 02/13: Suppress certain GTK diagnostics, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master c768da7e 06/13: Refactor, almost, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 35eb8545 09/13: Prefer a calculation with less roundoff error, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master c53ea12a 11/13: Reorder some statements in a unit test,
Greg Chicares <=
- [lmi-commits] [lmi] master 8b6d6dd8 12/13: Say DECIMAL_DIG wherever it's meant, Greg Chicares, 2022/05/09
- [lmi-commits] [lmi] master 3903a0c3 13/13: Record speed measurements, Greg Chicares, 2022/05/09