Beispiel #1
0
    def testMapSize(self, sizes=[0, 5, 50, 1000]):
        bio = compat.BytesIO()
        packer = Packer()
        for size in sizes:
            bio.write(packer.pack_map_header(size))
            for i in range(size):
                bio.write(packer.pack(i))  # key
                bio.write(packer.pack(i * 2))  # value

        bio.seek(0)
        unpacker = Unpacker(bio)
        for size in sizes:
            assert unpacker.unpack() == dict((i, i * 2) for i in range(size))
Beispiel #2
0
    def testMapSize(self, sizes=[0, 5, 50, 1000]):
        bio = compat.BytesIO()
        packer = Packer()
        for size in sizes:
            bio.write(packer.pack_map_header(size))
            for i in range(size):
                bio.write(packer.pack(i))  # key
                bio.write(packer.pack(i * 2))  # value

        bio.seek(0)
        unpacker = Unpacker(bio)
        for size in sizes:
            assert unpacker.unpack() == dict((i, i * 2) for i in range(size))
 def test_map_header(self):
     packer = Packer()
     packer.pack_map_header(2**32 - 1)
     self.assertRaises((OverflowError, ValueError),
                       packer.pack_array_header, 2**32)
Beispiel #4
0
 def test_map_header(self):
     packer = Packer()
     packer.pack_map_header(2 ** 32 - 1)
     self.assertRaises((OverflowError, ValueError),
                       packer.pack_array_header, 2 ** 32)