lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2666c48 06/15: Test rounding double to curren


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2666c48 06/15: Test rounding double to currency
Date: Mon, 25 Jan 2021 09:58:05 -0500 (EST)

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

    Test rounding double to currency
---
 round_to_test.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/round_to_test.cpp b/round_to_test.cpp
index da500db..26a9d5f 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -577,6 +577,20 @@ void round_to_test::test_fundamentals()
     BOOST_TEST(2 == round1.decimals());
     BOOST_TEST(r_to_nearest == round1.style());
 
+    // Test rounding double to currency.
+    currency c = round0.c(1.61803398875);
+    BOOST_TEST((1.62 - dblize(c)) < 1e-14);
+#if defined USE_CURRENCY_CLASS
+#   if defined CURRENCY_UNIT_IS_CENTS
+    BOOST_TEST_EQUAL(162, c.cents());
+#   else  // !defined CURRENCY_UNIT_IS_CENTS
+    // Arguably this isn't quite meaningful:
+    BOOST_TEST_EQUAL(1.62, c.cents());
+#   endif // !defined CURRENCY_UNIT_IS_CENTS
+#endif // defined USE_CURRENCY_CLASS
+//  c *= 0.61803398875;
+//  BOOST_TEST_EQUAL(1, c);
+
     // Test a vector.
     std::vector<double> const v0 {3.1415926535, 2.718281828};
     std::vector<double> const v1 {round0(v0)};



reply via email to

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