Sha256: 317c826e3e3f60dd3f88a1a0a28d7b911754cd4bcb9f1101695d59ebb17810d2

Contents?: true

Size: 1.76 KB

Versions: 33

Compression:

Stored size: 1.76 KB

Contents

from unittest import TestCase

import simplejson as json

class TestBigintAsString(TestCase):
    values = [(200, 200),
              ((2 ** 53) - 1, 9007199254740991),
              ((2 ** 53), '9007199254740992'),
              ((2 ** 53) + 1, '9007199254740993'),
              (-100, -100),
              ((-2 ** 53), '-9007199254740992'),
              ((-2 ** 53) - 1, '-9007199254740993'),
              ((-2 ** 53) + 1, -9007199254740991)]

    def test_ints(self):
        for val, expect in self.values:
            self.assertEquals(
                val,
                json.loads(json.dumps(val)))
            self.assertEquals(
                expect,
                json.loads(json.dumps(val, bigint_as_string=True)))

    def test_lists(self):
        for val, expect in self.values:
            val = [val, val]
            expect = [expect, expect]
            self.assertEquals(
                val,
                json.loads(json.dumps(val)))
            self.assertEquals(
                expect,
                json.loads(json.dumps(val, bigint_as_string=True)))

    def test_dicts(self):
        for val, expect in self.values:
            val = {'k': val}
            expect = {'k': expect}
            self.assertEquals(
                val,
                json.loads(json.dumps(val)))
            self.assertEquals(
                expect,
                json.loads(json.dumps(val, bigint_as_string=True)))

    def test_dict_keys(self):
        for val, _ in self.values:
            expect = {str(val): 'value'}
            val = {val: 'value'}
            self.assertEquals(
                expect,
                json.loads(json.dumps(val)))
            self.assertEquals(
                expect,
                json.loads(json.dumps(val, bigint_as_string=True)))

Version data entries

33 entries across 33 versions & 5 rubygems

Version Path
pygments.rb-1.2.1 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-1.2.0 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-1.1.2 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-1.1.1 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-1.1.0 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-1.0.0 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/pygments.rb-0.6.3/vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.6.3 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.6.2 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.6.1 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.6.0 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
mortar-pygments.rb-0.5.7 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
mortar-pygments.rb-0.5.6 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
mortar-pygments.rb-0.5.5 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-jruby-0.5.4.2 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-jruby-0.5.4.1 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-jruby-0.5.4 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
gitlab-pygments.rb-0.5.4 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.5.4 vendor/simplejson/simplejson/tests/test_bigint_as_string.py
pygments.rb-0.5.2 vendor/simplejson/simplejson/tests/test_bigint_as_string.py