]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/tests/model/test_currency.py
Add tests for Currency string conversion
[bluechips.git] / bluechips / tests / model / test_currency.py
index e3861ce3ea97a5e218f57a66672c4f454faa5269..5b4eba90fdb15640b289a331f9516b2af12399ad 100644 (file)
@@ -14,11 +14,21 @@ class TestCurrency(TestCase):
         """
         Make sure the constructor for Currency works with strings
         """
-        self.assertEqual(Currency("0.01"), Currency(1),
-                     "Currency string conversion breaks")
+        self.assertEqual(Currency("0.01"), Currency(1))
         self.assert_(Currency("0.01") is Currency(1),
                      "string and int constructors return different values")
     
+    def test_string(self):
+        """
+        Test converting a Currency to a string
+        """
+        self.assertEqual(str(Currency(1)), "$0.01")
+        self.assertEqual(str(Currency(100)), "$1.00")
+        self.assertEqual(str(Currency(101)), "$1.01")
+        self.assertEqual(str(Currency(-1)), "-$0.01")
+        self.assertEqual(str(Currency(-100)), "-$1.00")
+        self.assertEqual(str(Currency(-101)), "-$1.01")
+    
     def test_additionMath(self):
         """
         Confirm that addition works over currency types and ints