1cd701d438efd7bcbeacf15e0d1c241d11caf13c
[clinton/xbmc-groove.git] / resources / lib / simplejson / tests / test_decode.py
1 import decimal
2 from unittest import TestCase
3
4 import simplejson as json
5
6 class TestDecode(TestCase):
7 def test_decimal(self):
8 rval = json.loads('1.1', parse_float=decimal.Decimal)
9 self.assert_(isinstance(rval, decimal.Decimal))
10 self.assertEquals(rval, decimal.Decimal('1.1'))
11
12 def test_float(self):
13 rval = json.loads('1', parse_int=float)
14 self.assert_(isinstance(rval, float))
15 self.assertEquals(rval, 1.0)
16
17 def test_decoder_optimizations(self):
18 # Several optimizations were made that skip over calls to
19 # the whitespace regex, so this test is designed to try and
20 # exercise the uncommon cases. The array cases are already covered.
21 rval = json.loads('{ "key" : "value" , "k":"v" }')
22 self.assertEquals(rval, {"key":"value", "k":"v"})