Index: third_party/simplejson/simplejson/tests/test_decode.py |
diff --git a/third_party/simplejson/simplejson/tests/test_decode.py b/third_party/simplejson/simplejson/tests/test_decode.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..1cd701d438efd7bcbeacf15e0d1c241d11caf13c |
--- /dev/null |
+++ b/third_party/simplejson/simplejson/tests/test_decode.py |
@@ -0,0 +1,22 @@ |
+import decimal |
+from unittest import TestCase |
+ |
+import simplejson as json |
+ |
+class TestDecode(TestCase): |
+ def test_decimal(self): |
+ rval = json.loads('1.1', parse_float=decimal.Decimal) |
+ self.assert_(isinstance(rval, decimal.Decimal)) |
+ self.assertEquals(rval, decimal.Decimal('1.1')) |
+ |
+ def test_float(self): |
+ rval = json.loads('1', parse_int=float) |
+ self.assert_(isinstance(rval, float)) |
+ self.assertEquals(rval, 1.0) |
+ |
+ def test_decoder_optimizations(self): |
+ # Several optimizations were made that skip over calls to |
+ # the whitespace regex, so this test is designed to try and |
+ # exercise the uncommon cases. The array cases are already covered. |
+ rval = json.loads('{ "key" : "value" , "k":"v" }') |
+ self.assertEquals(rval, {"key":"value", "k":"v"}) |