lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/002 f7f87b2 42/65: unit test: overflow


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 f7f87b2 42/65: unit test: overflow
Date: Wed, 16 Sep 2020 16:55:19 -0400 (EDT)

branch: valyuta/002
commit f7f87b21ece5c3404410f419271e1a88153e8d6d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    unit test: overflow
---
 currency_test.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/currency_test.cpp b/currency_test.cpp
index 4b770db..9ac6ae2 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -89,6 +89,8 @@ std::cout << "int4: " << big_int4 << std::endl;
 std::cout << a3 << std::endl;
 std::cout << big_num << std::endl;
 std::cout << "rounded: " << round(big_num) << std::endl;
+
+    std::cout << "\ntoo big:" << std::endl;
     double too_big = std::numeric_limits<double>::max();
     currency a4(too_big);
 std::cout << a4 << std::endl;
@@ -96,6 +98,13 @@ std::cout << too_big << std::endl;
 std::cout << "rounded: " << round(too_big) << std::endl;
 std::cout << 100.0 * too_big << std::endl;
 
+    std::cout << "\nstill too big:" << std::endl;
+    BOOST_TEST_THROW
+        (currency(bourn_cast<currency::data_type>(too_big))
+        ,std::runtime_error
+        ,"Cast would transgress upper limit."
+        );
+
     currency b0(464.180000000000006821);
     currency b1(263.01999999999998181);
     currency b2(0.0);



reply via email to

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