Exemple #1
0
 def wu_helper(self, data):
     out_stream = StringIO()
     for x in data:
         if isinstance(x, int):
             srl.serialize_vint(x, out_stream)
         elif isinstance(x, basestring):
             wu.writeString(out_stream, x)
     return out_stream.getvalue()
Exemple #2
0
 def test_int(self):
     stream = self.stream
     for i in xrange(-16782, 16782):
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in xrange(-16782, 16782):
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
Exemple #3
0
 def test_int(self):
     stream = self.stream
     for i in xrange(-16782, 16782):
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in xrange(-16782, 16782):
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
 def wu_helper(self, data):
     out_stream = StringIO()
     for x in data:
         if isinstance(x, int):
             srl.serialize_vint(x, out_stream)
         elif isinstance(x, basestring):
             wu.writeString(out_stream, x)
     return out_stream.getvalue()
Exemple #5
0
 def test_int_big(self):
     stream = self.stream
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for i in numbers:
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in numbers:
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
Exemple #6
0
 def test_int_big(self):
     stream = self.stream
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for i in numbers:
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in numbers:
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
Exemple #7
0
 def test_simulate_java_output_1(self):
     try:
         byte_stream = _get_java_output_stream(self.wd)
         out_stream = StringIO()
         # write integers
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(4242, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(42424242, out_stream)
         srl.serialize_vint(-42, out_stream)
         # write longs
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(4242424242, out_stream)
         # strings
         wu.writeString(out_stream, u"hello world")
         # second has accented characters
         wu.writeString(out_stream, u"oggi è giovedì")
         #
         srl.serialize_text(u"à Text object", out_stream)
         self.assertEqual(byte_stream.getvalue(), out_stream.getvalue())
     finally:
         pass
Exemple #8
0
def writeVLong(stream, i):
    pser.serialize_vint(i, stream)
Exemple #9
0
def writeVLong(stream, i):
    pser.serialize_vint(i, stream)
 def test_simulate_java_output_1(self):
     try:
         byte_stream = _get_java_output_stream(self.wd)
         out_stream = StringIO()
         # write integers
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(4242, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(42424242, out_stream)
         srl.serialize_vint(-42, out_stream)
         # write longs
         srl.serialize_vint(42, out_stream)
         srl.serialize_vint(424242, out_stream)
         srl.serialize_vint(4242424242, out_stream)
         # strings
         wu.writeString(out_stream, u"hello world")
         # second has accented characters
         wu.writeString(out_stream, u"oggi è giovedì")
         #
         srl.serialize_text(u"à Text object", out_stream)
         self.assertEqual(byte_stream.getvalue(), out_stream.getvalue())
     finally:
         pass