summaryrefslogtreecommitdiff
path: root/tests/python/corelib/numerics
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-17 07:33:56 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:35:36 -0400
commitf63ce064612b0fb98b21ff3e36203c56fb081a7c (patch)
tree93765cc9138df581e5f0e879f2aa1a813782e0d2 /tests/python/corelib/numerics
parentf5956311af0425b6d1fd76752e84bd81a4c8ccd1 (diff)
downloadfork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.tar.gz
fork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.tar.bz2
fork-ledger-f63ce064612b0fb98b21ff3e36203c56fb081a7c.zip
Added stubs for several more commodity tests.
Diffstat (limited to 'tests/python/corelib/numerics')
-rw-r--r--tests/python/corelib/numerics/CommodityAmount.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/python/corelib/numerics/CommodityAmount.py b/tests/python/corelib/numerics/CommodityAmount.py
index 286418eb..417652e4 100644
--- a/tests/python/corelib/numerics/CommodityAmount.py
+++ b/tests/python/corelib/numerics/CommodityAmount.py
@@ -90,6 +90,10 @@ class CommodityAmountTestCase(unittest.TestCase):
self.assertEqual(amount("-123.45€"), - x9)
self.assertEqual(amount("123.45€"), - x10)
+ self.assertEqual(amount("$-123.45"), x1.negated())
+ self.assertEqual(amount("$123.45"), x2.negated())
+ self.assertEqual(amount("$123.45"), x3.negated())
+
self.assertEqual("$-123.45", (- x1).to_string())
self.assertEqual("$123.45", (- x2).to_string())
self.assertEqual("$123.45", (- x3).to_string())
@@ -101,6 +105,14 @@ class CommodityAmountTestCase(unittest.TestCase):
self.assertEqual("-123.45€", (- x9).to_string())
self.assertEqual("123.45€", (- x10).to_string())
+ x1.negate()
+ x2.negate()
+ x3.negate()
+
+ self.assertEqual(amount("$-123.45"), x1)
+ self.assertEqual(amount("$123.45"), x2)
+ self.assertEqual(amount("$123.45"), x3)
+
self.assertValid(x1)
self.assertValid(x2)
self.assertValid(x3)
@@ -158,6 +170,7 @@ class CommodityAmountTestCase(unittest.TestCase):
self.assertValid(x10)
def testEquality(self):
+ x0 = amount()
x1 = amount("$123.45")
x2 = amount("-$123.45")
x3 = amount("$-123.45")
@@ -169,6 +182,14 @@ class CommodityAmountTestCase(unittest.TestCase):
x9 = amount("123.45€")
x10 = amount("-123.45€")
+ self.assertTrue(x0.null())
+ self.assertTrue(x0.zero())
+ self.assertTrue(x0.realzero())
+ self.assertTrue(x0.sign() == 0)
+ self.assertTrue(x0.compare(x1) < 0)
+ self.assertTrue(x0.compare(x2) > 0)
+ self.assertTrue(x0.compare(x0) == 0)
+
self.assertTrue(x1 != x2)
self.assertTrue(x1 != x4)
self.assertTrue(x1 != x7)
@@ -179,6 +200,7 @@ class CommodityAmountTestCase(unittest.TestCase):
self.assertTrue(x7 == - x8)
self.assertTrue(x9 == - x10)
+ self.assertValid(x0)
self.assertValid(x1)
self.assertValid(x2)
self.assertValid(x3)