]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/tests/model/test_currency.py
Test Currency.__str_no_dollar__
[bluechips.git] / bluechips / tests / model / test_currency.py
index e3861ce3ea97a5e218f57a66672c4f454faa5269..a689778eea64c7c9f32d3d45bf73c31f6dd01b78 100644 (file)
@@ -14,11 +14,32 @@ 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_stringNoDollar(self):
+        """
+        Test that Currency values can be retrieved without the dollar sign
+        """
+        self.assertEqual(Currency(1).__str_no_dollar__(), "0.01")
+        self.assertEqual(Currency(100).__str_no_dollar__(), "1.00")
+        self.assertEqual(Currency(101).__str_no_dollar__(), "1.01")
+        self.assertEqual(Currency(-1).__str_no_dollar__(), "-0.01")
+        self.assertEqual(Currency(-100).__str_no_dollar__(), "-1.00")
+        self.assertEqual(Currency(-101).__str_no_dollar__(), "-1.01")
+    
     def test_additionMath(self):
         """
         Confirm that addition works over currency types and ints