summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/numerics/BasicAmount.cc3
-rw-r--r--tests/numerics/CommodityAmount.cc3
-rw-r--r--tests/python/numerics/BasicAmount.py3
-rw-r--r--tests/python/numerics/CommodityAmount.py3
4 files changed, 8 insertions, 4 deletions
diff --git a/tests/numerics/BasicAmount.cc b/tests/numerics/BasicAmount.cc
index f386d8f4..a6772b13 100644
--- a/tests/numerics/BasicAmount.cc
+++ b/tests/numerics/BasicAmount.cc
@@ -612,7 +612,8 @@ void BasicAmountTestCase::testFractionalConversion()
amount_t x1(1234.56);
assertEqual(true, bool(x1));
- assertEqual(1234L, x1.to_long());
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertEqual(1234L, x1.to_long(true));
assertEqual(1234.56, x1.to_double());
assertEqual(string("1234.56"), x1.to_string());
assertEqual(string("1234.56"), x1.quantity_string());
diff --git a/tests/numerics/CommodityAmount.cc b/tests/numerics/CommodityAmount.cc
index 611d2650..cc26bc80 100644
--- a/tests/numerics/CommodityAmount.cc
+++ b/tests/numerics/CommodityAmount.cc
@@ -466,7 +466,8 @@ void CommodityAmountTestCase::testConversion()
amount_t x1("$1234.56");
assertEqual(true, bool(x1));
- assertEqual(1234L, x1.to_long());
+ assertThrow(x1.to_long(), amount_error); // loses precision
+ assertEqual(1234L, x1.to_long(true));
assertEqual(1234.56, x1.to_double());
assertEqual(string("$1234.56"), x1.to_string());
assertEqual(string("1234.56"), x1.quantity_string());
diff --git a/tests/python/numerics/BasicAmount.py b/tests/python/numerics/BasicAmount.py
index 9e2c1b3e..9654f6a7 100644
--- a/tests/python/numerics/BasicAmount.py
+++ b/tests/python/numerics/BasicAmount.py
@@ -372,7 +372,8 @@ class BasicAmountTestCase(unittest.TestCase):
x1 = amount(1234.56)
self.assertTrue(x1)
- self.assertEqual(1234, int(x1))
+ self.assertRaises(exceptions.ArithmeticError, amount.to_long, x1)
+ self.assertEqual(1234, x1.to_long(True))
self.assertEqual(1234.56, float(x1))
self.assertEqual("1234.56", x1.to_string())
self.assertEqual("1234.56", x1.quantity_string())
diff --git a/tests/python/numerics/CommodityAmount.py b/tests/python/numerics/CommodityAmount.py
index 0edd9fad..3b7c98a9 100644
--- a/tests/python/numerics/CommodityAmount.py
+++ b/tests/python/numerics/CommodityAmount.py
@@ -449,7 +449,8 @@ class CommodityAmountTestCase(unittest.TestCase):
x1 = amount("$1234.56")
self.assertEqual(True, bool(x1))
- self.assertEqual(1234, int(x1))
+ self.assertRaises(exceptions.ArithmeticError, amount.to_long, x1)
+ self.assertEqual(1234, x1.to_long(True))
self.assertEqual(1234.56, float(x1))
self.assertEqual("$1234.56", x1.to_string())
self.assertEqual("1234.56", x1.quantity_string())