Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: third_party/simplejson/simplejson/tests/test_decode.py

Issue 159607: Extension docs build script, gyp target and PRESUBMIT.PY check (Closed)
Patch Set: remove build step on mac Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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"})

Powered by Google App Engine
This is Rietveld 408576698